Every multi-arch hydra image builds its arm64 half by running the whole Go toolchain inside an emulated arm64 container. It works, it is slow, and now that CI has moved onto our own runners the cost is wall-clock and disk on a box we own rather than billed GitHub minutes. nimsforest already builds the right way, so this is adopting an in-house pattern rather than inventing one.
I surveyed every repo with a local checkout on neoremote: 25 hydra repos push a multi-arch image (platforms: linux/amd64,linux/arm64) and none of them cross-compiles. Not one Dockerfile mentions TARGETARCH or BUILDPLATFORM. They all open with a bare
FROM golang:1.25-alpine AS build
so under buildx the arm64 leg runs apk add git, go mod download and go build inside QEMU user-mode emulation. The amd64 leg runs native. The arm64 leg does the same work several times slower.
The repos: hydraapplepipeline, hydrabiamp, hydrabodystatus, hydrabooks, hydrabrainserver, hydradistrict, hydraepiphan, hydraexperiencelibrary, hydragitwatcher, hydraissue, hydramancer, hydramirror, hydranorthstar, hydranps, hydraorganization, hydraperforce, hydrapipeline, hydraroar, hydrastreamingmonitor, hydratam, hydratransfer, hydraunrealengine-server, hydravenues, hydrawebsite. That is 24.
hydraadb is the 25th and is out of scope: it is FROM debian:bookworm-slim, not a Go build, so it needs its own look and should not be swept into this change.
nimsforest2, nimsforestadmin and nimsforestwebchat all cross-compile today. nimsforest2/Dockerfile:
FROM --platform=$BUILDPLATFORM golang:1.25.7-alpine AS builder
...
ARG TARGETOS
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-s -w -X main.version=${VERSION}" -o /forest ./cmd/forest
That is the whole trick. --platform=$BUILDPLATFORM pins the build stage to the runner's native architecture, and GOARCH tells Go what to emit. Go cross-compiles natively, so the arm64 binary is produced by a native amd64 toolchain at native speed.
All 24 already set CGO_ENABLED=0. That is the condition that makes this trivial: with cgo off there is no C toolchain to cross-target and no sysroot to install, so the change is three lines per Dockerfile and nothing else moves. The output is byte-for-byte the same static binary the emulated build produces, reached by a different route.
The runtime stage still runs emulated, because FROM alpine:3.21 + RUN apk add --no-cache ca-certificates executes arm64 package tooling. That is a handful of seconds against a full module download and compile, and leaving it alone keeps the change small. Worth revisiting only if apk turns out to be a flake source.
FROM golang:1.25-alpine AS build becomes FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS build.ARG TARGETOS and ARG TARGETARCH in the build stage, next to the existing ARG VERSION.GOOS=$TARGETOS GOARCH=$TARGETARCH, keeping CGO_ENABLED=0 and the existing -trimpath and -ldflags.No workflow change. platforms: stays as it is; buildx already passes TARGETOS and TARGETARCH, they are simply not being read.
docker buildx imagetools inspect <registry>/<name>:<tag> and confirm both linux/amd64 and linux/arm64 are present. Most of these workflows already assert this and will catch a regression themselves.One repo first, all the way through to a running container on a pi node, then the rest. hydrabodystatus or hydratam is the right pilot: small, already exercised on the org runner, and recently released so a comparison is available. Do not batch 24 Dockerfile edits before one of them has been proven on real hardware.
The survey covers repos checked out on neoremote. A hydra repo with no local checkout will not appear in the list above and should be swept separately.
Noticed while reviewing hydravenues' move to a self-hosted org runner. On hosted runners the emulated leg was billed minutes and invisible; on our own boxes it is wall-clock and build cache on a shared machine that is already at 69% disk. Raised there, and deliberately kept out of the migration so the move changed one variable at a time. Background on the runner move: hydracluster docs/runbooks/github-org-migration.md, commit 736d0f7.