add flake support, build docker image with nix
continuous-integration/drone Build is running Details
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Garionion 2022-01-14 17:02:03 +01:00
parent f3290ff6df
commit becfe3ec51
7 changed files with 150 additions and 14 deletions

View File

@ -3,20 +3,45 @@ type: docker
name: default name: default
steps: steps:
- name: build - name: build docker image
image: golang image: "nixos/nix"
environment:
USER: root
commands: 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 - name: push docker image
image: techknowlogick/drone-docker:latest image: docker:dind
privileged: true volumes:
settings: - name: image
repo: garionion/gitea-attachements-proxy path: /image
debug: true - name: dockersock
password: path: /var/run/
from_secret: docker_password commands:
username: - 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 from_secret: docker_username
tags: DOCKER_PASSWORD:
- latest 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: {}

1
.envrc Normal file
View File

@ -0,0 +1 @@
use nix

7
default.nix Normal file
View File

@ -0,0 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
mkShell {
nativeBuildInputs = [
go_1_17
];
}

17
docker.nix Normal file
View 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
View 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
View 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
View 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";
};
}