diff --git a/.drone.yml b/.drone.yml index 4d1cc72..2d5ac48 100644 --- a/.drone.yml +++ b/.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: {} diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..65326bb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix \ No newline at end of file diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..8978c53 --- /dev/null +++ b/default.nix @@ -0,0 +1,7 @@ +{ pkgs ? import { } }: +with pkgs; +mkShell { + nativeBuildInputs = [ + go_1_17 + ]; +} \ No newline at end of file diff --git a/docker.nix b/docker.nix new file mode 100644 index 0000000..6fa2594 --- /dev/null +++ b/docker.nix @@ -0,0 +1,17 @@ +{ pkgs ? import {} }: + +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 = "/"; + }; +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c46589a --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c13a7e1 --- /dev/null +++ b/flake.nix @@ -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;}; + } + ); +} \ No newline at end of file diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..40f180c --- /dev/null +++ b/package.nix @@ -0,0 +1,30 @@ +{ pkgs ? import { } }: +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"; + }; +} \ No newline at end of file