Skip to content

build: cross-compile the multi-arch image instead of emulating it - #24

Merged
aceforeverd merged 1 commit into
modelsphere:mainfrom
huskcass:build/no-qemu
Oct 28, 2026
Merged

aceforeverd merged 1 commit into
modelsphere:mainfrom
huskcass:build/no-qemu

Conversation

@huskcass

Copy link
Copy Markdown
Collaborator

The manager is pure Go, so the arm64 image doesn't need QEMU. Same approach as modelsphere/console#107.

  • Dockerfile: the builder stage is FROM --platform=$BUILDPLATFORM ${GO_IMAGE} and cross-compiles with CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH. Only the distroless runtime stage is per-target, and it has no RUN steps, so nothing runs under emulation.
  • release.yml: drop docker/setup-qemu-action (buildx stays), and drop its pin from actions.lock (regenerated with gh actions-lock).
  • Makefile: docker-buildx used to sed --platform=${BUILDPLATFORM} into a Dockerfile.cross. The Dockerfile has that flag now, so the target builds from Dockerfile directly instead of adding the flag twice.

Verified locally on an amd64 host with no binfmt/QEMU handlers registered: docker buildx build --platform linux/amd64,linux/arm64 . succeeds (linux/amd64->arm64 builder step), and file reports the binaries as x86-64 and ARM aarch64. go build ./... passes.

The manager is pure Go, so the builder stage now runs on the build
platform and cross-compiles for TARGETOS/TARGETARCH; only the
distroless runtime stage is per-target and it has no RUN steps. The
arm64 image therefore needs no QEMU.

Drop docker/setup-qemu-action from the release workflow (and its
actions.lock pin), and let docker-buildx use the Dockerfile directly
now that it already carries --platform=$BUILDPLATFORM.

Co-authored-by: aceforeverd <11715200+aceforeverd@users.noreply.github.com>
@aceforeverd
aceforeverd merged commit 2953c6f into modelsphere:main Oct 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants