From 301190e42746fc03eb4cbef9bd6d080c4b8e23fd Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 May 2022 22:09:31 +0200 Subject: [PATCH] Build ARM docker image in GitHub Actions using QEMU (#400) This PR updates the GH Action docker workflow to crossbuild the docker image for ARM using QEMU. This theoratically works but takes about for a clean build 2.5 hours, which may or may not be tolerable for each commit on `main`. A action run where the dependencies are already cached needs about 15 minutes with this PR. --- .github/workflows/docker.yaml | 4 ++++ Dockerfile | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 8a616db..8f1855a 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -19,6 +19,9 @@ jobs: - name: Check Out Repo uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Docker meta id: meta uses: docker/metadata-action@v3 @@ -51,6 +54,7 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index c34ba40..408d399 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,10 @@ COPY . . RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder + +# Ensure working C compile setup (not installed by default in arm64 images) +RUN apt update && apt install build-essential -y + COPY --from=planner /app/recipe.json recipe.json RUN cargo chef cook --release --recipe-path recipe.json