Skip to content

Commit 88973d2

Browse files
authored
Use buildx to publish multi-arch images (#9)
* Use buildx to publish multi-arch images * Use docker-container driver
1 parent 20df3ac commit 88973d2

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ jobs:
3030
- name: Install jq
3131
run: sudo apt-get install -y jq
3232

33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
with:
36+
platforms: arm64
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
with:
41+
driver: docker-container
42+
3343
- name: Run build script
3444
run: ./build.sh
3545
env:

build-alpine.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
source common.sh
3+
platforms="${PLATFORMS:-linux/amd64,linux/arm64}"
34
docker-tags alpine |
45
while read tag; do
56
dockerfile=$(mktemp)
@@ -9,9 +10,9 @@ RUN sed -i \
910
-e 's/dl-.*.alpinelinux.org/mirrors.ustc.edu.cn/g' \
1011
/etc/apk/repositories
1112
EOF
12-
docker build -f $dockerfile -t ustclug/alpine:$tag .
13-
docker tag ustclug/alpine:$tag ghcr.io/ustclug/alpine:$tag
14-
docker push ustclug/alpine:$tag
15-
docker push ghcr.io/ustclug/alpine:$tag
13+
docker buildx build --platform "$platforms" -f $dockerfile \
14+
-t ustclug/alpine:$tag \
15+
-t ghcr.io/ustclug/alpine:$tag \
16+
--push .
1617
rm $dockerfile
1718
done

build-debian.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
source common.sh
3+
platforms="${PLATFORMS:-linux/amd64,linux/arm64}"
34
docker-tags debian |
45
while read tag; do
56
unset backports_list
@@ -17,9 +18,9 @@ RUN sed -i \
1718
-e 's/security.debian.org/mirrors.ustc.edu.cn/g' \
1819
/etc/apt/sources.list.d/debian.sources $backports_list
1920
EOF
20-
docker build -f $dockerfile -t ustclug/debian:$tag .
21-
docker tag ustclug/debian:$tag ghcr.io/ustclug/debian:$tag
22-
docker push ustclug/debian:$tag
23-
docker push ghcr.io/ustclug/debian:$tag
21+
docker buildx build --platform "$platforms" -f $dockerfile \
22+
-t ustclug/debian:$tag \
23+
-t ghcr.io/ustclug/debian:$tag \
24+
--push .
2425
rm $dockerfile
2526
done

build-fedora.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
source common.sh
3+
platforms="${PLATFORMS:-linux/amd64,linux/arm64}"
34
docker-tags fedora |
45
while read tag; do
56
dockerfile=$(mktemp)
@@ -11,9 +12,9 @@ FROM fedora:$tag
1112
RUN $sedcommand /etc/yum.repos.d/fedora-modular.repo /etc/yum.repos.d/fedora-updates-modular.repo || true \
1213
&& $sedcommand /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora-updates.repo
1314
EOF
14-
docker build -f $dockerfile -t ustclug/fedora:$tag .
15-
docker tag ustclug/fedora:$tag ghcr.io/ustclug/fedora:$tag
16-
docker push ustclug/fedora:$tag
17-
docker push ghcr.io/ustclug/fedora:$tag
15+
docker buildx build --platform "$platforms" -f $dockerfile \
16+
-t ustclug/fedora:$tag \
17+
-t ghcr.io/ustclug/fedora:$tag \
18+
--push .
1819
rm $dockerfile
1920
done

build-rocky.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
source common.sh
3+
platforms="${PLATFORMS:-linux/amd64,linux/arm64}"
34
docker-tags rockylinux |
45
while read tag; do
56
dockerfile=$(mktemp)
@@ -16,9 +17,9 @@ RUN sed -i \
1617
-e 's|dl.rockylinux.org/\$contentdir|mirrors.ustc.edu.cn/rocky|g' \
1718
/etc/yum.repos.d/rocky*.repo
1819
EOF
19-
docker build -f $dockerfile -t ustclug/rocky:$tag .
20-
docker tag ustclug/rocky:$tag ghcr.io/ustclug/rocky:$tag
21-
docker push ustclug/rocky:$tag
22-
docker push ghcr.io/ustclug/rocky:$tag
20+
docker buildx build --platform "$platforms" -f $dockerfile \
21+
-t ustclug/rocky:$tag \
22+
-t ghcr.io/ustclug/rocky:$tag \
23+
--push .
2324
rm $dockerfile
2425
done

build-ubuntu.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
source common.sh
3+
platforms="${PLATFORMS:-linux/amd64,linux/arm64}"
34
docker-tags ubuntu |
45
while read tag; do
56
echo $tag | grep -q '-' && continue
@@ -15,9 +16,9 @@ RUN sed -i \
1516
-e 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' \
1617
/etc/apt/sources.list.d/ubuntu.sources || true
1718
EOF
18-
docker build -f $dockerfile -t ustclug/ubuntu:$tag .
19-
docker tag ustclug/ubuntu:$tag ghcr.io/ustclug/ubuntu:$tag
20-
docker push ustclug/ubuntu:$tag
21-
docker push ghcr.io/ustclug/ubuntu:$tag
19+
docker buildx build --platform "$platforms" -f $dockerfile \
20+
-t ustclug/ubuntu:$tag \
21+
-t ghcr.io/ustclug/ubuntu:$tag \
22+
--push .
2223
rm $dockerfile
2324
done

0 commit comments

Comments
 (0)