Skip to content

Commit

Permalink
ci: update docker manifest creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Feb 3, 2024
1 parent 13ea36c commit 094224d
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 94 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ jobs:
contents: write
packages: write
steps:
- uses: actions/checkout@v3
# - uses: docker/setup-qemu-action@v2
# with:
# platforms: arm64
- uses: cachix/install-nix-action@v22
# with:
# extra_nix_config: |
# extra-platforms = aarch64-linux
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: DeterminateSystems/nix-installer-action@v9
with:
extra-conf: |
extra-platforms = aarch64-linux
- uses: DeterminateSystems/magic-nix-cache-action@v3
- uses: cihelper/action-semanticrelease-npm@v1
id: semanticrelease
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- run: nix run .#dockerManifest --impure
if: ${{ steps.semanticrelease.outputs.released == 'true' }}
env:
VERSION: ${{ steps.semanticrelease.outputs.version }}
GH_TOKEN: ${{ github.token }}
166 changes: 85 additions & 81 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,102 @@
flake = false;
};
flocken = {
url = "github:mirkolenz/flocken/v1";
url = "github:mirkolenz/flocken/v2";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {
nixpkgs,
flake-parts,
systems,
flocken,
self,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
outputs =
inputs@{
nixpkgs,
flake-parts,
systems,
flocken,
self,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
perSystem = {
pkgs,
system,
lib,
self',
...
}: let
nodejs = pkgs.nodejs_20;
npmlock2nix = import inputs.npmlock2nix {inherit pkgs;};
caddyport = "8080";
caddyfile = pkgs.writeText "caddyfile" ''
{
admin off
auto_https off
persist_config off
}
:${caddyport} {
root * ${self'.packages.default}
encode gzip
file_server {
index index.html
perSystem =
{
pkgs,
system,
lib,
self',
...
}:
let
nodejs = pkgs.nodejs_20;
npmlock2nix = import inputs.npmlock2nix { inherit pkgs; };
caddyport = "8080";
caddyfile = pkgs.writeText "caddyfile" ''
{
admin off
auto_https off
persist_config off
}
:${caddyport} {
root * ${self'.packages.default}
encode gzip
file_server {
index index.html
}
}
}
'';
in {
devShells.default = pkgs.mkShell {
shellHook = ''
${lib.getExe' nodejs "npm"} install
${lib.getExe nodejs} --version > .node-version
'';
packages = [nodejs];
};
apps.dockerManifest = {
type = "app";
program = lib.getExe (flocken.legacyPackages.${system}.mkDockerManifest {
branch = builtins.getEnv "GITHUB_REF_NAME";
name = "ghcr.io/" + builtins.getEnv "GITHUB_REPOSITORY";
version = builtins.getEnv "VERSION";
images = with self.packages; [x86_64-linux.docker aarch64-linux.docker];
});
};
packages = {
default = npmlock2nix.v2.build {
src = ./.;
installPhase = "cp -r dist/. $out";
buildCommands = [
"HOME=$TMPDIR"
"npm run build"
];
node_modules_attrs = {
inherit nodejs;
# Python is needed for node-gyp/libsass
buildInputs = with pkgs; [python3];
};
};
arguemapper = self'.packages.default;
server = pkgs.writeShellApplication {
name = "server";
text = ''
${lib.getExe pkgs.caddy} run --config ${caddyfile} --adapter caddyfile
in
{
devShells.default = pkgs.mkShell {
shellHook = ''
${lib.getExe' nodejs "npm"} install
${lib.getExe nodejs} --version > .node-version
'';
packages = [ nodejs ];
};
docker = pkgs.dockerTools.buildLayeredImage {
name = "arguemapper";
tag = "latest";
created = "now";
contents = [
pkgs.dockerTools.fakeNss
];
config = {
entrypoint = [(lib.getExe self'.packages.server)];
exposedPorts = {
"${caddyport}/tcp" = {};
packages = {
default = npmlock2nix.v2.build {
src = ./.;
installPhase = "cp -r dist/. $out";
buildCommands = [
"HOME=$TMPDIR"
"npm run build"
];
node_modules_attrs = {
inherit nodejs;
# Python is needed for node-gyp/libsass
buildInputs = with pkgs; [ python3 ];
};
user = "nobody:nobody";
};
arguemapper = self'.packages.default;
server = pkgs.writeShellApplication {
name = "server";
text = ''
${lib.getExe pkgs.caddy} run --config ${caddyfile} --adapter caddyfile
'';
};
docker = pkgs.dockerTools.buildLayeredImage {
name = "arguemapper";
tag = "latest";
created = "now";
contents = [ pkgs.dockerTools.fakeNss ];
config = {
entrypoint = [ (lib.getExe self'.packages.server) ];
exposedPorts = {
"${caddyport}/tcp" = { };
};
user = "nobody:nobody";
};
};
};
legacyPackages.dockerManifest = flocken.legacyPackages.${system}.mkDockerManifest {
github = {
enable = true;
token = builtins.getEnv "GH_TOKEN";
};
version = builtins.getEnv "VERSION";
images = with self.packages; [
x86_64-linux.docker
aarch64-linux.docker
];
};
};
};
};
}

0 comments on commit 094224d

Please sign in to comment.