Conversation
Set up QEMU emulation and Docker Buildx in CI workflow to enable cross-platform Docker builds for ARM64 architecture. Problem: ARM64 builds were failing with "exec format error" because we're building on AMD64 hosts without proper emulation: - "The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3)" - "exec /bin/sh: exec format error" Solution: 1. Add docker/setup-qemu-action to enable ARM64 emulation 2. Add docker/setup-buildx-action to set up Docker Buildx 3. Re-add "use: buildx" to goreleaser.yaml for multi-arch builds 4. Both actions run before GoReleaser executes How it works: - QEMU provides ARM64 CPU emulation on AMD64 hosts - Buildx uses QEMU to build ARM64 container images - GoReleaser uses buildx to build both amd64 and arm64 images - docker_manifests combines them into multi-arch images - Images are pushed directly (no --load flag conflict) Changes: - Add "Set up QEMU" step using docker/setup-qemu-action@v3 - Add "Set up Docker Buildx" step using docker/setup-buildx-action@v3 - Re-add "use: buildx" for both amd64 and arm64 builds - Steps only run on main branch releases Result: - ARM64 builds work on AMD64 CI runners - Multi-arch Docker images published successfully
ReviewConcern: Running inside container with mounted Docker socket. Workflow runs in container (line 24-29) with Verification needed: Alternative approach: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Set up QEMU emulation and Docker Buildx in CI workflow to enable cross-platform Docker builds for ARM64 architecture.
Problem
ARM64 builds were failing with "exec format error" because we're building on AMD64 hosts without proper emulation:
The issue occurred because:
use: buildxin Fix Docker buildx multi-arch build with --load flag error #149 to fix --load errorSolution
docker/setup-qemu-actionto enable ARM64 emulationdocker/setup-buildx-actionto set up Docker Buildxuse: buildxto goreleaser.yaml for multi-arch buildsHow It Works
Changes
docker/setup-qemu-action@v3docker/setup-buildx-action@v3use: buildxfor both amd64 and arm64 builds in .goreleaser.yamlResult
Testing
After merge, the next release will successfully build and publish multi-arch Docker images.
Fixes #151