Skip to content

Commit

Permalink
Merge pull request #513 from nbuchwitz/devel/add-arm64-support
Browse files Browse the repository at this point in the history
docker: Add arm64 builds to Dockerfile and CI
  • Loading branch information
obbardc authored Oct 30, 2024
2 parents 25468f1 + e0b59e1 commit 277e7d3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
29 changes: 28 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Build and Test

env:
GITHUB_TAG: ghcr.io/${{ github.repository }}
DOCKER_TARGET_PLATFORMS: linux/amd64,linux/arm64

on:
push:
Expand Down Expand Up @@ -51,6 +52,9 @@ jobs:
- name: Repository checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -67,6 +71,26 @@ jobs:
push: false
pull: true
file: docker/Dockerfile
platforms: ${{ env.DOCKER_TARGET_PLATFORMS }}
tags: debos
cache-from: type=local,src=/tmp/.build-cache
cache-to: type=local,dest=/tmp/.build-cache,mode=max

# WORKAROUND:
# Docker buildx cannot export multi-platform images with type=docker,
# but only with type=oci. The latter cannot be imported without an
# intermediate registry. Thus export only the amd64 image for usage
# in the test stage.
#
# see https://docs.docker.com/reference/cli/docker/buildx/build/#docker
- name: Export amd64 Docker image for later usage
uses: docker/build-push-action@v6
with:
context: .
push: false
pull: true
file: docker/Dockerfile
platforms: linux/amd64
tags: debos
cache-from: type=local,src=/tmp/.build-cache
cache-to: type=local,dest=/tmp/.build-cache,mode=max
Expand Down Expand Up @@ -109,7 +133,7 @@ jobs:

- name: Run unit tests
run: |
docker-compose -f docker/unit-tests.test.yml \
docker compose -f docker/unit-tests.test.yml \
up --exit-code-from=sut
recipe-tests:
Expand Down Expand Up @@ -158,6 +182,7 @@ jobs:
with:
name: debos-image
path: /tmp

- name: Load image
run: |
docker load --input /tmp/debos-image.tar
Expand Down Expand Up @@ -241,6 +266,7 @@ jobs:
with:
context: .
push: true
platforms: ${{ env.DOCKER_TARGET_PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: docker/Dockerfile
Expand Down Expand Up @@ -320,6 +346,7 @@ jobs:
with:
context: .
push: true
platforms: ${{ env.DOCKER_TARGET_PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: docker/Dockerfile
Expand Down
24 changes: 19 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG DEBIAN_FRONTEND=noninteractive
ARG GOPATH=/usr/local/go

### first stage - builder ###
FROM debian:bookworm-slim as builder
FROM debian:bookworm-slim AS builder

ARG DEBIAN_FRONTEND
ARG GOPATH
Expand Down Expand Up @@ -34,7 +34,24 @@ COPY docker/get-archlinux-keyring.sh /
RUN /get-archlinux-keyring.sh /arch-keyring

### second stage - runner ###
FROM debian:bookworm-slim as runner
FROM debian:bookworm-slim AS runner-amd64
RUN apt-get update && \
apt-get install -y --no-install-recommends \
linux-image-amd64 \
qemu-system-x86 \
user-mode-linux && \
rm -rf /var/lib/apt/lists/*

FROM debian:bookworm-slim AS runner-arm64
RUN apt-get update && \
apt-get install -y --no-install-recommends \
linux-image-arm64 \
qemu-system-arm \
# fixes: qemu-system-aarch64: failed to find romfile "efi-virtio.rom"
ipxe-qemu && \
rm -rf /var/lib/apt/lists/*

FROM runner-${TARGETARCH} AS runner

ARG DEBIAN_FRONTEND
ARG GOPATH
Expand Down Expand Up @@ -78,11 +95,9 @@ RUN apt-get update && \
pigz \
libostree-1-1 \
libslirp-helper \
linux-image-amd64 \
openssh-client \
parted \
pkg-config \
qemu-system-x86 \
qemu-user-static \
qemu-utils \
rsync \
Expand All @@ -91,7 +106,6 @@ RUN apt-get update && \
systemd-resolved \
u-boot-tools \
unzip \
user-mode-linux \
xfsprogs \
xz-utils \
zip \
Expand Down

0 comments on commit 277e7d3

Please sign in to comment.