convert to flake based container
parent
888d891498
commit
f85f1b5934
|
@ -0,0 +1 @@
|
|||
result
|
24
Dockerfile
24
Dockerfile
|
@ -1,24 +0,0 @@
|
|||
ARG GO_VERSION="1.19"
|
||||
|
||||
FROM golang:$GO_VERSION-alpine as builder
|
||||
|
||||
RUN \
|
||||
set -o errexit -o nounset -o xtrace; \
|
||||
go install github.com/google/go-containerregistry/cmd/crane@latest
|
||||
|
||||
FROM alpine:3
|
||||
|
||||
RUN \
|
||||
set -o errexit -o nounset -o xtrace; \
|
||||
apk add --no-cache --update \
|
||||
ca-certificates \
|
||||
dumb-init \
|
||||
gzip \
|
||||
tzdata \
|
||||
su-exec\
|
||||
;
|
||||
|
||||
ADD docker-entrypoint.sh /bin/
|
||||
COPY --from=builder /go/bin/crane /bin/
|
||||
|
||||
ENTRYPOINT docker-entrypoint.sh
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/dumb-init /bin/sh
|
||||
# shellcheck shell=sh
|
||||
|
||||
set -o errexit -o nounset
|
||||
|
||||
crane auth login -u "$PLUGIN_USERNAME" -p "$PLUGIN_PASSWORD" "$PLUGIN_REPO"
|
||||
|
||||
set -o xtrace
|
||||
|
||||
gunzip < image.tar.gz > image.tar
|
||||
|
||||
crane push image.tar "$PLUGIN_REPO/$PLUGIN_IMAGE:$PLUGIN_TAG"
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1670064435,
|
||||
"narHash": "sha256-+ELoY30UN+Pl3Yn7RWRPabykwebsVK/kYE9JsIsUMxQ=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "61a8a98e6d557e6dd7ed0cdb54c3a3e3bbc5e25c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
description = "an container for mdbook with the toc plugin";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
let inherit (flake-utils.lib) eachSystem system;
|
||||
in eachSystem [ system.x86_64-linux ] (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
entrypoint = pkgs.writeScriptBin "entrypoint.sh" ''
|
||||
#!/bin/env sh
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
set -o xtrace
|
||||
|
||||
# Login to the registry
|
||||
crane auth login -u "$PLUGIN_USERNAME" -p "$PLUGIN_PASSWORD" "$PLUGIN_REPO"
|
||||
|
||||
# Build container
|
||||
nix build --extra-experimental-features nix-command --extra-experimental-features flake ".#$PLUGIN_PACKAGE"
|
||||
|
||||
# Convert to tar
|
||||
gunzip < image.tar.gz > image.tar
|
||||
|
||||
# Push container
|
||||
crane push image.tar "$PLUGIN_REPO/$PLUGIN_IMAGE:$PLUGIN_TAG"
|
||||
'';
|
||||
in {
|
||||
packages = {
|
||||
docker = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "push-nix-container";
|
||||
contents = [
|
||||
(pkgs.buildEnv {
|
||||
name = "build-env";
|
||||
paths = with pkgs; [ busybox nixUnstable crane git ];
|
||||
})
|
||||
];
|
||||
config.Cmd = [ "${entrypoint}/bin/entrypoint.sh" ];
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue