From b993bc09556935e1c0b9bc685bf9da4b1115a331 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Thu, 19 Jan 2023 17:07:55 +0000 Subject: [PATCH] Build docker image for multiple architectures including ARM This is based on https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ which doesn't use QEMU --- .github/workflows/docker-publish.yml | 4 ++++ Dockerfile | 4 ++-- doc/docker.md | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index dad55339..a70eea6c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -23,6 +23,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log into registry ${{ env.REGISTRY }} uses: docker/login-action@v2 with: @@ -42,3 +45,4 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64,linux/arm/v7 diff --git a/Dockerfile b/Dockerfile index f35dc559..4d8be56b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/node:alpine as builder +FROM --platform=${BUILDPLATFORM} docker.io/node:alpine as builder RUN apk add --no-cache git python3 build-base WORKDIR /app @@ -10,7 +10,7 @@ RUN yarn install COPY . /app RUN yarn build -FROM docker.io/nginx:alpine +FROM --platform=${BUILDPLATFORM} docker.io/nginx:alpine # Copy the dynamic config script COPY ./docker/dynamic-config.sh /docker-entrypoint.d/99-dynamic-config.sh diff --git a/doc/docker.md b/doc/docker.md index db779fe1..752c492f 100644 --- a/doc/docker.md +++ b/doc/docker.md @@ -35,7 +35,9 @@ To stop the container, simply hit `ctrl+c`. In this repository, create a Docker image: -``` +```sh +# Enable BuildKit https://docs.docker.com/develop/develop-images/build_enhancements/ +export DOCKER_BUILDKIT=1 docker build -t hydrogen . ```