Developers complain builds are slow on Apple Silicon for amd64 targets.
AdvancedScenarioMulti-stage builds, cache, tags and registries
Answer
Situation read → QEMU emulation of amd64 is 5–20x slower.
What I'd do →
- Cross-compile natively:
FROM --platform=$BUILDPLATFORM golang AS buildand setGOOS=$TARGETOS GOARCH=$TARGETARCH. - Use remote native builders:
docker buildx create --name farm --node amd64 --platform linux/amd64 ssh://builderplus a local arm64 node. - Enable Rosetta in Docker Desktop for amd64 emulation where needed.
- Build multi-arch in CI on native runners and merge manifests.
Why → Native or cross-compile beats emulation.
Interview tip → Languages without easy cross-compilers need native nodes.
More on Multi-stage builds, cache, tags and registries
Show a multi-stage Dockerfile for a Java Spring Boot app and explain what you gain.BeginnerCI rebuilds from scratch every run and takes 12 minutes. How do you bring it down?IntermediateYou tag every build `myapp:latest`. A rollback is requested. What happens?BeginnerHow do you promote an image from dev to prod registry without rebuilding?IntermediateDisk on the build server keeps filling up with images.BeginnerWhen do you use `--no-cache` and when is it a smell?Beginner