Skip to content
Latchkey

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=max

Notes

  • setup-qemu-action enables cross-platform emulation.
  • The platforms list 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

Run this faster and cheaper on Latchkey managed runners. Start free →