From 95cf80c71d78cf727015675bed5b79b8752ef300 Mon Sep 17 00:00:00 2001 From: Marvin Preuss Date: Tue, 24 Sep 2024 10:33:40 +0200 Subject: [PATCH] build: multi arch docker images --- .gitignore | 2 +- Taskfile.yml | 44 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index c649679..e41b6fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .direnv result - +result-* dist/ diff --git a/Taskfile.yml b/Taskfile.yml index 13c4dce..09ff4ab 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -8,6 +8,7 @@ tasks: cmds: - task: clean - task: lint + - task: docker-build-all - task: test-all ci-publish: @@ -15,27 +16,53 @@ tasks: - task: clean - task: lint - task: test-all - - task: docker-publish + - task: docker-publish-all clean: cmds: - - rm -rf result + - rm -rf result-* docker-build: + requires: + vars: + - ARCH status: - - test -f result + - test -f result-{{.ARCH}} cmds: - - nix build .#docker + - nix build .#docker --option system {{.ARCH}} + - mv result result-{{.ARCH}} + + docker-build-all: + cmds: + - for: + - x86_64-linux + - aarch64-linux + task: docker-build + vars: + ARCH: "{{.ITEM}}" + + docker-publish-all: + cmds: + - for: + - x86_64-linux + - aarch64-linux + task: docker-publish + vars: + ARCH: "{{.ITEM}}" docker-local-import: + vars: + ARCH: '{{default "x86_64-linux" .ARCH}}' cmds: - task: docker-build + vars: + ARCH: "{{.ARCH}}" - | {{.NIX_CMD_BASE}} \ skopeo \ --insecure-policy \ copy \ - docker-archive:$(readlink -f result) \ + docker-archive:$(readlink -f result-{{.ARCH}}) \ docker-daemon:caddy-log-exporter:NOTUSE - | {{.NIX_CMD_BASE}} \ @@ -46,19 +73,22 @@ tasks: docker-publish: requires: vars: + - ARCH - GITHUB_USERNAME - GITHUB_PASSWORD - GIT_TAG cmds: - task: docker-build + vars: + ARCH: "{{.ARCH}}" - | {{.NIX_CMD_BASE}} \ skopeo \ --insecure-policy \ copy \ --dest-username {{.GITHUB_USERNAME}} --dest-password {{.GITHUB_PASSWORD}} \ - docker-archive:$(readlink -f result) \ - docker://ghcr.io/xsteadfastx/caddy-log-exporter:{{.GIT_TAG}} + docker-archive:$(readlink -f result-{{.ARCH}}) \ + docker://ghcr.io/xsteadfastx/caddy-log-exporter-{{.ARCH}}:{{.GIT_TAG}} docker-inspect: cmds: