first nixified version
All checks were successful
Build and push nixos-based docker container / build (push) Successful in 27s
All checks were successful
Build and push nixos-based docker container / build (push) Successful in 27s
This commit is contained in:
commit
75a8924e57
25
.github/workflows/build.yaml
vendored
Normal file
25
.github/workflows/build.yaml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
name: Build and push nixos-based docker container
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
REGISTRY: git.strudelline.net
|
||||
PACKAGE: cascade/docker-node-red
|
||||
REGISTRY_AUTH_FILE: ./registry-auth.json
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: nix
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: pwd
|
||||
- run: |
|
||||
set -x
|
||||
skopeo login --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASSWORD }} "$REGISTRY"
|
||||
stringprefix() { [ ${#1} -le $2 ] && echo $1 && return 0 || stringprefix "${1%?}" $2 ; }
|
||||
SHORTSHA="$(stringprefix "$GITHUB_SHA" 8)"
|
||||
for TAG in "$SHORTSHA" "$GITHUB_REF_NAME";do
|
||||
nix run .#upload-image "docker://$REGISTRY/$PACKAGE:$TAG"
|
||||
done
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
.*
|
||||
!.git?*
|
||||
|
||||
*~
|
||||
\#*#
|
||||
result
|
61
flake.lock
Normal file
61
flake.lock
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1722421184,
|
||||
"narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
38
flake.nix
Normal file
38
flake.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
description = "docker builder for cascade's node-red";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
streamImage = pkgs.dockerTools.streamLayeredImage {
|
||||
name = "node-red";
|
||||
config.Cmd = [ "${pkgs.nodePackages.node-red}/bin/node-red" ];
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
packages.upload-image = pkgs.writeScriptBin "upload" ''
|
||||
${streamImage} | ${pkgs.skopeo}/bin/skopeo copy docker-archive:/dev/stdin "$@"
|
||||
'';
|
||||
|
||||
packages.stream-image = streamImage;
|
||||
|
||||
packages.default = pkgs.writeScriptBin "help" ''
|
||||
echo ${lib.escapeShellArg ''
|
||||
nixos-based docker node-red image builder
|
||||
|
||||
usage:
|
||||
|
||||
nix run .#stream-image | docker load
|
||||
nix run .#upload-image docker://registry.where/it/goes:its4tag
|
||||
''}
|
||||
|
||||
'';
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user