GitHub Actions Workflow for Build a Multi-Arch Image
Build one Docker image for both amd64 and arm64.
This workflow sets up QEMU and Buildx, then builds a manifest covering both architectures in a single push.
The workflow
.github/workflows/docker.yml
name: Docker
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=maxNotes
setup-qemu-actionenables cross-platform emulation.- The
platformslist produces a multi-arch manifest. - arm64 emulation is slow -- native arm runners build it far faster.
Run it cheaper
Point runs-on: at a Latchkey label to run this workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.
Related guides
GitHub Actions Workflow for Build and Push to GHCRA GitHub Actions workflow that builds a Docker image and pushes it to GitHub Container Registry with layer ca…
How to Cache Docker Layers in GitHub ActionsSpeed up Docker builds in GitHub Actions with BuildKit registry cache - cache-from/cache-to, gha cache backen…
Docker "failed to solve" BuildKit Errors - Diagnose and FixDecode Docker BuildKit "ERROR: failed to solve" messages in CI - missing files, bad cache mounts, network fai…