Skip to content

Commit 64f9c3a

Browse files
authored
Add multi-architecture image build (#314)
1 parent 8c59a34 commit 64f9c3a

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@ jobs:
1919
if: github.repository == 'itzg/docker-minecraft-bedrock-server'
2020

2121
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v3
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v2
2424

2525
- name: Set up Docker Buildx
2626
uses: docker/setup-buildx-action@v2
2727

28-
- name: Cache Docker layers
29-
uses: actions/cache@v3
30-
with:
31-
path: /tmp/.buildx-cache
32-
key: ${{ runner.os }}-buildx-${{ github.sha }}
33-
restore-keys: |
34-
${{ runner.os }}-buildx-
35-
3628
- name: Login to DockerHub
3729
if: github.event_name != 'pull_request'
3830
uses: docker/login-action@v2
@@ -42,17 +34,18 @@ jobs:
4234

4335
- name: Docker Metadata action
4436
id: meta
45-
uses: docker/metadata-action@v4.3.0
37+
uses: docker/metadata-action@v4
4638
with:
4739
images: itzg/minecraft-bedrock-server
4840
flavor: |
49-
latest=${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
41+
latest=${{ github.event_name == 'push' && github.ref_name == 'master' }}
5042
5143
- name: Build and push
52-
uses: docker/build-push-action@v3
44+
uses: docker/build-push-action@v4
5345
with:
54-
context: .
5546
push: ${{ github.event_name != 'pull_request' }}
47+
provenance: false
48+
platforms: linux/amd64,linux/arm64
5649
tags: ${{ steps.meta.outputs.tags }}
5750
labels: |
5851
${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
FROM debian
22

3-
# ARCH is only set to avoid repetition in Dockerfile, use --build-arg ARCH=arm64 for arm cpu
4-
ARG ARCH=amd64
5-
6-
ARG APT_UPDATE=20210112
3+
# hook into docker BuildKit --platform support
4+
# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
5+
ARG TARGETARCH
76

87
RUN apt-get update && \
98
DEBIAN_FRONTEND=noninteractive apt-get install -y \
@@ -14,7 +13,7 @@ RUN apt-get update && \
1413
&& rm -rf /var/lib/apt/lists/*
1514

1615
# Instal box64 on arm
17-
RUN if [ "$ARCH" = "arm64" ] ; then \
16+
RUN if [ "$TARGETARCH" = "arm64" ] ; then \
1817
apt-get update && \
1918
DEBIAN_FRONTEND=noninteractive apt-get install -y debian-keyring && \
2019
curl -L https://ryanfortner.github.io/box64-debs/box64.list -o /etc/apt/sources.list.d/box64.list && \
@@ -34,16 +33,16 @@ WORKDIR /data
3433
ENTRYPOINT ["/usr/local/bin/entrypoint-demoter", "--match", "/data", "--debug", "--stdin-on-term", "stop", "/opt/bedrock-entry.sh"]
3534

3635
ARG EASY_ADD_VERSION=0.7.0
37-
ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VERSION}/easy-add_linux_${ARCH} /usr/local/bin/easy-add
36+
ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VERSION}/easy-add_linux_${TARGETARCH} /usr/local/bin/easy-add
3837
RUN chmod +x /usr/local/bin/easy-add
3938

40-
RUN easy-add --var version=0.4.0 --var app=entrypoint-demoter --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/v{{.version}}/{{.app}}_{{.version}}_linux_${ARCH}.tar.gz
39+
RUN easy-add --var version=0.4.0 --var app=entrypoint-demoter --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/v{{.version}}/{{.app}}_{{.version}}_linux_${TARGETARCH}.tar.gz
4140

42-
RUN easy-add --var version=0.1.1 --var app=set-property --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${ARCH}.tar.gz
41+
RUN easy-add --var version=0.1.1 --var app=set-property --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${TARGETARCH}.tar.gz
4342

44-
RUN easy-add --var version=1.6.1 --var app=restify --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${ARCH}.tar.gz
43+
RUN easy-add --var version=1.6.1 --var app=restify --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${TARGETARCH}.tar.gz
4544

46-
RUN easy-add --var version=0.5.0 --var app=mc-monitor --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${ARCH}.tar.gz
45+
RUN easy-add --var version=0.5.0 --var app=mc-monitor --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${TARGETARCH}.tar.gz
4746

4847
COPY *.sh /opt/
4948

0 commit comments

Comments
 (0)