flake: add docker image
This commit is contained in:
parent
0fce9e09c4
commit
0d0e88af1f
5 changed files with 52 additions and 34 deletions
38
.github/workflows/deploy.yml
vendored
Normal file
38
.github/workflows/deploy.yml
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
name: "Deploy"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v21
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-stable
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
system-features = nixos-test benchmark big-parallel kvm
|
||||
- uses: cachix/cachix-action@v12
|
||||
with:
|
||||
name: pad-archiver
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
- run: nix --experimental-features 'nix-command flakes' build .#dockerImage -L
|
||||
- run: docker load -i ./result/image.tar.gz
|
||||
- run: docker tag pad-archiver ${{ env.IMAGE_NAME }}
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
16
.github/workflows/docker-image.yml
vendored
16
.github/workflows/docker-image.yml
vendored
|
@ -1,16 +0,0 @@
|
|||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build the Docker image
|
||||
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
|
11
Dockerfile
11
Dockerfile
|
@ -1,11 +0,0 @@
|
|||
FROM golang:1.19
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . .
|
||||
RUN go build -v -o /usr/local/bin/pad-archiver ./...
|
||||
|
||||
CMD ["pad-archiver"]
|
18
flake.nix
18
flake.nix
|
@ -10,16 +10,22 @@
|
|||
in
|
||||
rec {
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
|
||||
packages = flake-utils.lib.flattenTree {
|
||||
pad-archiver = pkgs.callPackage ./nix { pkgs = pkgs; };
|
||||
gitAndTools = pkgs.gitAndTools;
|
||||
packages = flake-utils.lib.flattenTree rec {
|
||||
pad-archiver = pkgs.callPackage ./nix { };
|
||||
dockerImage = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "pad-archiver";
|
||||
tag = "latest";
|
||||
contents = [ pad-archiver ];
|
||||
config = {
|
||||
Cmd = [ "${pad-archiver}/bin/pad-archiver" ];
|
||||
WorkingDir = "/data";
|
||||
Volumes = { "/data" = { }; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
checks = {
|
||||
nix-format = pkgs.runCommand "nix-format" { buildInputs = [ formatter ]; } "nixpkgs-fmt --check ${./.} && touch $out";
|
||||
};
|
||||
|
||||
defaultPackage = packages.pad-archiver;
|
||||
apps.pad-archiver = flake-utils.lib.mkApp { drv = packages.pad-archiver; };
|
||||
defaultApp = apps.pad-archiver;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
{ pkgs, lib, buildGoModule }:
|
||||
{ lib, buildGoModule }:
|
||||
buildGoModule {
|
||||
pname = "pad-archiver";
|
||||
version = "0.0.1";
|
||||
src = ../.;
|
||||
vendorSha256 = "sha256-vBni3j3o0P13PJg/Ab1ux9zSVr05Iha/sb8dVTX4G0g=";
|
||||
ldflags = [ "-s" "-w" ];
|
||||
meta = with lib; {
|
||||
description = "Archives Etherpads with git";
|
||||
homepage = "https://github.com/dadada/pad-archiver";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue