add flake support, build docker image with nix
This commit is contained in:
parent
f3290ff6df
commit
becfe3ec51
53
.drone.yml
53
.drone.yml
|
@ -3,20 +3,45 @@ type: docker
|
|||
name: default
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang
|
||||
- name: build docker image
|
||||
image: "nixos/nix"
|
||||
environment:
|
||||
USER: root
|
||||
commands:
|
||||
- CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' .
|
||||
- nix-channel --update
|
||||
- nix-build docker.nix
|
||||
- cp $(readlink result) /image/docker.tgz
|
||||
volumes:
|
||||
- name: image
|
||||
path: /image
|
||||
|
||||
- name: publish
|
||||
image: techknowlogick/drone-docker:latest
|
||||
privileged: true
|
||||
settings:
|
||||
repo: garionion/gitea-attachements-proxy
|
||||
debug: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
username:
|
||||
- name: push docker image
|
||||
image: docker:dind
|
||||
volumes:
|
||||
- name: image
|
||||
path: /image
|
||||
- name: dockersock
|
||||
path: /var/run/
|
||||
commands:
|
||||
- docker load -i /image/docker.tgz
|
||||
- echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin https://registry-1.docker.io/
|
||||
- docker push garionion/gitea-attachements-proxy
|
||||
environment:
|
||||
DOCKER_USERNAME:
|
||||
from_secret: docker_username
|
||||
tags:
|
||||
- latest
|
||||
DOCKER_PASSWORD:
|
||||
from_secret: docker_password
|
||||
|
||||
services:
|
||||
- name: docker
|
||||
image: docker:dind
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run
|
||||
|
||||
volumes:
|
||||
- name: image
|
||||
temp: {}
|
||||
- name: dockersock
|
||||
temp: {}
|
||||
|
|
7
default.nix
Normal file
7
default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
with pkgs;
|
||||
mkShell {
|
||||
nativeBuildInputs = [
|
||||
go_1_17
|
||||
];
|
||||
}
|
17
docker.nix
Normal file
17
docker.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
let
|
||||
callPackage = pkgs.lib.callPackageWith pkgs;
|
||||
gitea-attachements-proxy = callPackage ./package.nix { };
|
||||
in
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "garionion/gitea-attachements-proxy";
|
||||
tag = "latest";
|
||||
|
||||
contents = [ pkgs.cacert gitea-attachements-proxy ];
|
||||
|
||||
config = {
|
||||
Cmd = [ "/bin/gitea-attachements-proxy" ];
|
||||
WorkingDir = "/";
|
||||
};
|
||||
}
|
41
flake.lock
Normal file
41
flake.lock
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1638122382,
|
||||
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1642069818,
|
||||
"narHash": "sha256-666w6j8wl/bojfgpp0k58/UJ5rbrdYFbI2RFT2BXbSQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "46821ea01c8f54d2a20f5a503809abfc605269d7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
15
flake.nix
Normal file
15
flake.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
description = "gitea-attachements-proxy";
|
||||
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system}; in
|
||||
{
|
||||
devShell = import ./default.nix { inherit pkgs; };
|
||||
defaultPackage = import ./package.nix { inherit pkgs;};
|
||||
}
|
||||
);
|
||||
}
|
30
package.nix
Normal file
30
package.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
with pkgs;
|
||||
let
|
||||
version = "0.0.1";
|
||||
deps = [];
|
||||
nativeDeps = [
|
||||
];
|
||||
in
|
||||
pkgs.buildGo117Module {
|
||||
pname = "gitea-attachements-proxy";
|
||||
inherit version;
|
||||
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [
|
||||
] ++deps;
|
||||
nativeBuildInputs = [
|
||||
] ++nativeDeps;
|
||||
|
||||
tags = [ ];
|
||||
|
||||
allowGoReference = true;
|
||||
|
||||
vendorSha256 = "sha256-9ppXRHVSzXyEvCx+5ZOB+A//THbl/5k2wRy+jLaRUkE=";
|
||||
|
||||
meta = {
|
||||
description = "A Wrapper around the gitea API to get attachments by tags";
|
||||
homepage = "https://git.entr0py.de/garionion/gitea-attachements-proxy";
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue