From f970090aeeaeae71ba93267c825f0b69be98d663 Mon Sep 17 00:00:00 2001 From: Wynne Pirini Date: Thu, 22 Oct 2026 12:05:30 +1300 Subject: [PATCH 1/2] build(docker): cross-compile instead of emulating, and bound the build time docker-publish builds linux/amd64,linux/arm64 and the Dockerfile built both stages for the target platform, so under buildx the arm64 leg ran pnpm install, pnpm build, go mod download and go build under QEMU. That is slow and sometimes hangs outright: a run was cancelled at exactly 6h0m44s, which is GitHub's default 360-minute job timeout, because the job set none. Neither stage needs emulation. The frontend output is architecture-independent, and CGO is disabled so Go cross-compiles natively from GOARCH=$TARGETARCH. Pin both builder stages to $BUILDPLATFORM; the runtime stage keeps defaulting to the target platform. Measured locally with buildx (docker-container driver): amd64 image 118s cold arm64 image 37s with the frontend stage cached, because it is now built once rather than once per platform combined index contains linux/amd64 and linux/arm64 manifests Both images verified by extracting the binaries: calnode and litestream are x86-64 in the amd64 image and aarch64 in the arm64 image, and the amd64 image starts cleanly. Also add timeout-minutes: 60 to the job, so a hang fails in an hour instead of six. --- .github/workflows/docker-publish.yml | 11 ++++++++--- Dockerfile | 25 +++++++++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 6be6f3fb..8df160bc 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,9 +29,14 @@ env: # casing (${{ github.repository }} would break the push). IMAGE_NAME: calnode/calnode -jobs: - build: - runs-on: ubuntu-latest + jobs: + build: + runs-on: ubuntu-latest + # Without this the job inherits GitHub's 360-minute default, so a hung + # multi-arch build sits for six hours before being cancelled (observed on + # #129's branch, cancelled at exactly 6h0m44s). Normal duration is 11-13 + # minutes, so an hour is a generous ceiling that fails visibly instead. + timeout-minutes: 60 permissions: contents: read packages: write diff --git a/Dockerfile b/Dockerfile index f5318f7d..09e31654 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,11 @@ # syntax=docker/dockerfile:1 # ── Frontend build stage ─────────────────────────────────────────────────────── -FROM node:22-alpine AS frontend-builder +# Built for the BUILD platform, not the target: the output is static JS/CSS that is +# identical for every architecture. Without this pin a multi-arch build (buildx: +# linux/amd64,linux/arm64) runs pnpm install and pnpm build a second time under QEMU +# for arm64, which is slow and occasionally hangs for hours. +FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend-builder # Pin pnpm to the version in package.json's `packageManager` field (not @latest) # so CI builds are reproducible and match the committed lockfile. @@ -16,7 +20,11 @@ COPY frontend/ . RUN pnpm build # ── Go build stage ───────────────────────────────────────────────────────────── -FROM golang:1.27.2-alpine AS builder +# Also the BUILD platform. CGO is disabled, so Go cross-compiles natively to the +# target arch; there is no reason for this stage to run under QEMU. Running it +# emulated is what made a multi-arch build stall: the arm64 leg spent its time +# interpreting the compiler instead of compiling. +FROM --platform=$BUILDPLATFORM golang:1.27.2-alpine AS builder RUN apk add --no-cache ca-certificates wget @@ -28,10 +36,10 @@ RUN go mod download COPY . . COPY --from=frontend-builder /app/build ./frontend/build -# Build natively for whatever architecture this stage is running on -# (TARGETARCH is auto-populated by Docker buildx; falls back correctly -# on ARM hosts where the original hardcoded amd64 would produce a -# binary that can't execute at all). +# Build for the TARGET architecture from this (build-platform) stage. buildx +# populates TARGETARCH; with no CGO this is a native cross-compile, not emulation. +# A plain `docker build` on an arm64 host still works: TARGETARCH then matches the +# host, so the binary executes there as before. ARG TARGETARCH # VERSION is passed by docker-publish.yml from the resolved image tag (semver on a # release, "edge"/branch on a plain main push); defaults to "dev" for local builds @@ -55,8 +63,9 @@ RUN wget -qO- \ # ── Runtime stage ───────────────────────────────────────────────────────────── # alpine (not scratch) — needed for the shell entrypoint and Litestream. -# No --platform pin here: inherits the build host's native architecture, -# matching whatever TARGETARCH the binary above was actually compiled for. +# No --platform pin: under buildx this defaults to the TARGET platform, which is +# what we want (an arm64 final image for arm64 consumers). Only the two builder +# stages above are pinned to BUILDPLATFORM. FROM alpine:3.24 RUN apk add --no-cache ca-certificates tzdata From 7472586ca45f20d32075b35e220f89a150cc14db Mon Sep 17 00:00:00 2001 From: Wynne Pirini Date: Thu, 22 Oct 2026 12:07:00 +1300 Subject: [PATCH 2/2] fix(ci): restore the build job indentation The previous commit shifted the whole jobs block two spaces, which made permissions and steps siblings of build rather than children, so GitHub rejected the workflow (jobs with no runs-on) and the run had zero jobs. Indentation now matches the file's existing style exactly and the parsed workflow has jobs.build with runs-on, timeout-minutes, permissions and steps. --- .github/workflows/docker-publish.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8df160bc..4e89fed0 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,14 +29,14 @@ env: # casing (${{ github.repository }} would break the push). IMAGE_NAME: calnode/calnode - jobs: - build: - runs-on: ubuntu-latest - # Without this the job inherits GitHub's 360-minute default, so a hung - # multi-arch build sits for six hours before being cancelled (observed on - # #129's branch, cancelled at exactly 6h0m44s). Normal duration is 11-13 - # minutes, so an hour is a generous ceiling that fails visibly instead. - timeout-minutes: 60 +jobs: + build: + runs-on: ubuntu-latest + # Without this the job inherits GitHub's 360-minute default, so a hung + # multi-arch build sits for six hours before being cancelled (observed on + # one branch, cancelled at exactly 6h0m44s). Normal duration is 11-13 + # minutes, so an hour is a generous ceiling that fails visibly instead. + timeout-minutes: 60 permissions: contents: read packages: write