Skip to content

Commit 5d6fb8e

Browse files
committed
try multi-arch docker
1 parent 20397c9 commit 5d6fb8e

File tree

3 files changed

+127
-7
lines changed

3 files changed

+127
-7
lines changed

Diff for: .github/workflows/ci.yaml

+30-6
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,33 @@ jobs:
166166
authToken: '${{ secrets.ATTIC_TOKEN }}'
167167
- run: nix build --option system ${{ matrix.machine.platform }}
168168

169+
170+
build-docker:
171+
runs-on: ubuntu-latest
172+
needs: [build, build-parser]
173+
strategy:
174+
matrix:
175+
machine:
176+
- platform: x86_64-linux
177+
- platform: aarch64-linux
178+
steps:
179+
- uses: actions/checkout@v4
180+
- if: matrix.machine.platform != 'x86_64-linux'
181+
uses: docker/setup-qemu-action@v3
182+
- uses: cachix/install-nix-action@v26
183+
with:
184+
extra_nix_config: |
185+
extra-platforms = aarch64-linux
186+
- uses: icewind1991/attic-action@v1
187+
with:
188+
name: ci
189+
instance: https://cache.icewind.me
190+
authToken: '${{ secrets.ATTIC_TOKEN }}'
191+
- run: nix build --option system ${{ matrix.machine.platform }} .#demostf-api-docker
192+
169193
docker:
170194
runs-on: ubuntu-latest
171-
needs: [build, build-parser, api, phpunit]
195+
needs: [build-docker, api, phpunit]
172196
steps:
173197
- name: Checkout code
174198
uses: actions/checkout@v4
@@ -177,9 +201,9 @@ jobs:
177201
with:
178202
name: ci
179203
instance: https://cache.icewind.me
180-
authToken: '${{ secrets.ATTIC_TOKEN }}'
181-
- run: nix build .#docker
182-
- name: Push image
204+
- run: nix run --impure .#dockerManifest
183205
if: github.ref == 'refs/heads/master'
184-
run: |
185-
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://demostf/api"
206+
env:
207+
VERSION: "1.0.0"
208+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
209+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

Diff for: flake.lock

+76-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: flake.nix

+21
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
inputs = {
33
nixpkgs.url = "nixpkgs/release-23.11";
44
utils.url = "github:numtide/flake-utils";
5+
flocken = {
6+
url = "github:mirkolenz/flocken/v2";
7+
inputs.nixpkgs.follows = "nixpkgs";
8+
};
59
};
610

711
outputs = {
812
self,
913
nixpkgs,
1014
utils,
15+
flocken,
1116
}:
1217
utils.lib.eachDefaultSystem (system: let
18+
inherit (builtins) getEnv;
1319
overlays = [
1420
(import ./overlay.nix)
1521
];
@@ -22,11 +28,26 @@
2228
nodeLd = pkgs.writeShellScriptBin "node" ''
2329
LD=$CC ${pkgs.nodejs_20}/bin/node $@
2430
'';
31+
inherit (flocken.legacyPackages.${system}) mkDockerManifest;
2532
in rec {
2633
packages = rec {
2734
inherit (pkgs) demostf-api demostf-api-docker demostf-parser;
2835
docker = demostf-api-docker;
2936
default = demostf-api;
37+
38+
dockerManifest = mkDockerManifest {
39+
tags = ["latest"];
40+
registries = {
41+
"docker" = {
42+
enable = true;
43+
repo = "demostf/api";
44+
username = "$DOCKERHUB_USERNAME";
45+
password = "$DOCKERHUB_TOKEN";
46+
};
47+
};
48+
version = getEnv "VERSION";
49+
images = with self.packages; [x86_64-linux.demostf-api-docker aarch64-linux.demostf-api-docker];
50+
};
3051
};
3152
devShells.default = pkgs.mkShell {
3253
nativeBuildInputs = with pkgs; [

0 commit comments

Comments
 (0)