Build a multi-arch (amd64 + arm64) image (!4)
Build / build-and-push (push) Successful in 6m7s

Co-authored-by: Aneurin Barker Snook <aneurin@aneur.in>
This commit was merged in pull request #4.
This commit is contained in:
2026-09-07 00:42:58 +00:00
committed by aneurin
parent 2c288ca1e2
commit 7f57e25dcf
4 changed files with 36 additions and 18 deletions
+3 -2
View File
@@ -1,3 +1,4 @@
# Build context only needs the prebuilt ./zampler binary and the Dockerfile.
# Build context only needs the prebuilt per-arch binaries and the Dockerfile.
*
!zampler
!dist/zampler-linux-amd64
!dist/zampler-linux-arm64
+23 -11
View File
@@ -12,9 +12,10 @@ jobs:
image: golang:1.26-alpine
env:
CGO_ENABLED: "0"
IMAGE: code.aneur.in/${{ gitea.repository }}
steps:
- name: Install toolchain deps
run: apk add --no-cache nodejs npm docker-cli git tar
run: apk add --no-cache nodejs npm docker-cli docker-cli-buildx git tar
- uses: actions/checkout@v4
@@ -42,8 +43,17 @@ jobs:
npm ci
npx vite build --outDir ../internal/server/static --emptyOutDir
- name: Build binary
run: go build -ldflags="-s -w" -o zampler .
- name: Cross-compile binaries
run: |
for arch in amd64 arm64; do
GOOS=linux GOARCH="$arch" \
go build -ldflags="-s -w" -o "dist/zampler-linux-$arch" .
done
- name: Set up Docker buildx
run: |
docker buildx rm multi 2>/dev/null || true
docker buildx create --name multi --driver docker-container --use
- name: Log in to the container registry
env:
@@ -52,14 +62,16 @@ jobs:
- name: Promote current "latest" to "previous"
run: |
IMAGE="code.aneur.in/${{ gitea.repository }}"
if docker pull "$IMAGE:latest"; then
docker tag "$IMAGE:latest" "$IMAGE:previous"
docker push "$IMAGE:previous"
if docker buildx imagetools inspect "$IMAGE:latest" >/dev/null 2>&1; then
docker buildx imagetools create -t "$IMAGE:previous" "$IMAGE:latest"
else
echo "No existing :latest to promote; skipping."
fi
- name: Build and push "latest"
- name: Build and push multi-arch "latest"
run: |
IMAGE="code.aneur.in/${{ gitea.repository }}:latest"
docker build -t "$IMAGE" .
docker push "$IMAGE"
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag "$IMAGE:latest" \
--push \
.
+1
View File
@@ -4,3 +4,4 @@
zampler.files
zampler.sqlite3
internal/server/static
dist
+9 -5
View File
@@ -1,12 +1,16 @@
# The zampler binary is built in CI (.gitea/workflows/build.yml) so the compile
# can use a persistent Go module + build cache. This image is just the runtime
# wrapper around the prebuilt static binary.
# The zampler binaries are cross-compiled in CI (.gitea/workflows/build.yml) so
# the compile can use a persistent Go module + build cache and avoid emulation.
# This image is just the runtime wrapper around the prebuilt static binary;
# buildx sets TARGETARCH per platform and we copy the matching binary.
#
# For a local build: `go build -o zampler .` first, then `docker build .`.
# For a local build:
# GOOS=linux GOARCH=amd64 go build -o dist/zampler-linux-amd64 .
# docker build --build-arg TARGETARCH=amd64 .
FROM alpine:3.24
COPY zampler /usr/local/bin/zampler
ARG TARGETARCH
COPY dist/zampler-linux-${TARGETARCH} /usr/local/bin/zampler
ENTRYPOINT ["zampler"]
CMD ["-s", "/db/zampler.sqlite3", "/data"]