Skip to content

Commit b993bc0

Browse files
committed
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
1 parent 8ee62c3 commit b993bc0

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.github/workflows/docker-publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
- name: Checkout repository
2424
uses: actions/checkout@v3
2525

26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
2629
- name: Log into registry ${{ env.REGISTRY }}
2730
uses: docker/login-action@v2
2831
with:
@@ -42,3 +45,4 @@ jobs:
4245
push: ${{ github.event_name != 'pull_request' }}
4346
tags: ${{ steps.meta.outputs.tags }}
4447
labels: ${{ steps.meta.outputs.labels }}
48+
platforms: linux/amd64,linux/arm64,linux/arm/v7

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/node:alpine as builder
1+
FROM --platform=${BUILDPLATFORM} docker.io/node:alpine as builder
22
RUN apk add --no-cache git python3 build-base
33

44
WORKDIR /app
@@ -10,7 +10,7 @@ RUN yarn install
1010
COPY . /app
1111
RUN yarn build
1212

13-
FROM docker.io/nginx:alpine
13+
FROM --platform=${BUILDPLATFORM} docker.io/nginx:alpine
1414

1515
# Copy the dynamic config script
1616
COPY ./docker/dynamic-config.sh /docker-entrypoint.d/99-dynamic-config.sh

doc/docker.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ To stop the container, simply hit `ctrl+c`.
3535

3636
In this repository, create a Docker image:
3737

38-
```
38+
```sh
39+
# Enable BuildKit https://docs.docker.com/develop/develop-images/build_enhancements/
40+
export DOCKER_BUILDKIT=1
3941
docker build -t hydrogen .
4042
```
4143

0 commit comments

Comments
 (0)