Skip to content

Commit d79f48f

Browse files
Harry-Chenshankerwangmiao
authored andcommitted
Use arm64 runner instead of QEMU
Signed-off-by: Shengqi Chen <[email protected]>
1 parent b2e66bd commit d79f48f

File tree

1 file changed

+90
-34
lines changed

1 file changed

+90
-34
lines changed

.github/workflows/docker-images.yml

Lines changed: 90 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: docker-images
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- master
77
- docker-test
88
pull_request:
9-
branches:
9+
branches:
1010
- master
1111
- docker-test
1212
workflow_dispatch:
@@ -16,52 +16,41 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
image:
19+
image:
2020
- ftpsync
2121
- nix-channels
2222
- pub-mirror
2323
- rubygems-mirror
2424
- rustup-mirror
2525
- shadowmire
2626
- tsumugu
27+
- tunasync-scripts
2728
# - freighter
29+
os:
30+
- ubuntu-latest
31+
- ubuntu-24.04-arm
2832
include:
2933
- image: tunasync-scripts
30-
dockerfile: .
34+
dockerfile_dir: .
3135
# - image: julia-mirror
3236
# dockerfile: dockerfiles/julia
3337

34-
runs-on: ubuntu-latest
38+
runs-on: ${{ matrix.os }}
3539
steps:
36-
-
37-
name: Determin docker tag
38-
env:
39-
TAG_NAME: ${{ github.ref }}
40-
run: |
41-
if [ "${TAG_NAME##*/}" = "master" ]; then
42-
tag=latest
43-
else
44-
tag=build-test
45-
fi
46-
echo "docker_tag=${tag}" >> $GITHUB_ENV
47-
-
48-
name: Determin dockerfile
40+
-
41+
name: Determine dockerfile dir
42+
id: docker_file_dir
4943
env:
50-
DF: ${{ matrix.dockerfile }}
44+
DF: ${{ matrix.dockerfile_dir }}
5145
IMG: ${{ matrix.image }}
5246
run: |
5347
if [ -z "${DF}" ]; then
5448
DF="dockerfiles/${IMG}"
5549
fi
56-
echo "docker_file=${DF}" >> $GITHUB_ENV
50+
echo "docker_file_dir=${DF}" >> $GITHUB_OUTPUT
5751
-
5852
name: Checkout
5953
uses: actions/checkout@v5
60-
-
61-
name: Set up QEMU
62-
uses: docker/setup-qemu-action@v3
63-
with:
64-
platforms: arm64
6554
-
6655
name: Set up Docker Buildx
6756
uses: docker/setup-buildx-action@v3
@@ -71,19 +60,21 @@ jobs:
7160
if: github.event_name == 'push'
7261
with:
7362
path: /tmp/.buildx-cache
74-
key: ${{ runner.os }}-buildx-${{ matrix.image }}-${{ github.sha }}
63+
key: ${{ runner.os }}-${{ runner.arch }}-buildx-${{ matrix.image }}-${{ matrix.os }}-${{ github.sha }}
7564
restore-keys: |
76-
${{ runner.os }}-buildx-${{ matrix.image }}-
65+
${{ runner.os }}-${{ runner.arch }}-buildx-${{ matrix.image }}-${{ matrix.os }}-
66+
${{ runner.os }}-${{ runner.arch }}-buildx-${{ matrix.image }}-
7767
-
7868
name: Cache Docker layers
7969
uses: actions/cache@v4
8070
if: github.event_name == 'pull_request'
8171
with:
8272
path: /tmp/.buildx-cache
83-
key: ${{ runner.os }}-pr-${{ github.event.pull_request.head.user.login }}-buildx-${{ matrix.image }}-${{ github.sha }}
73+
key: ${{ runner.os }}-${{ runner.arch }}-pr-${{ github.event.pull_request.head.user.login }}-buildx-${{ matrix.image }}-${{ matrix.os }}-${{ github.sha }}
8474
restore-keys: |
85-
${{ runner.os }}-pr-${{ github.event.pull_request.head.user.login }}-buildx-${{ matrix.image }}-
86-
${{ runner.os }}-buildx-${{ matrix.image }}-
75+
${{ runner.os }}-${{ runner.arch }}-pr-${{ github.event.pull_request.head.user.login }}-buildx-${{ matrix.image }}-${{ matrix.os }}-
76+
${{ runner.os }}-${{ runner.arch }}-buildx-${{ matrix.image }}-${{ matrix.os }}-
77+
${{ runner.os }}-${{ runner.arch }}-buildx-${{ matrix.image }}-
8778
-
8879
name: Cache Docker layers
8980
if: github.event_name != 'push' && github.event_name != 'pull_request'
@@ -99,12 +90,77 @@ jobs:
9990
password: ${{ secrets.DOCKERHUB_TOKEN }}
10091
-
10192
name: Build and push
102-
uses: docker/build-push-action@v5
93+
uses: docker/build-push-action@v6
94+
id: dockerbuild
10395
with:
10496
context: .
105-
file: ${{ env.docker_file }}/Dockerfile
106-
platforms: linux/amd64,linux/arm64
97+
file: ${{ steps.docker_file_dir.outputs.docker_file_dir }}/Dockerfile
10798
push: ${{ github.event_name == 'push' }}
108-
tags: tunathu/${{ matrix.image }}:${{ env.docker_tag }}
99+
tags: tunathu/${{ matrix.image }}
109100
cache-from: type=local,src=/tmp/.buildx-cache
110101
cache-to: type=local,dest=/tmp/.buildx-cache
102+
outputs: ${{ github.event_name == 'push' && 'type=image,push-by-digest=true,name-canonical=true,push=true' || 'type=image' }}
103+
-
104+
name: Export digest
105+
run: |
106+
mkdir -p ${{ runner.temp }}/digests/${{ matrix.image }}
107+
digest="${{ steps.dockerbuild.outputs.digest }}"
108+
touch "${{ runner.temp }}/digests/${{ matrix.image }}/${digest#sha256:}"
109+
-
110+
name: Upload digest
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: digests-${{ matrix.image }}-${{ matrix.os }}
114+
path: ${{ runner.temp }}/digests/*
115+
if-no-files-found: error
116+
retention-days: 1
117+
118+
merge:
119+
runs-on: ubuntu-latest
120+
needs:
121+
- multi
122+
if: always() && github.event_name == 'push'
123+
steps:
124+
-
125+
name: Determine docker tag
126+
id: docker_tag
127+
env:
128+
TAG_NAME: ${{ github.ref }}
129+
run: |
130+
if [ "${TAG_NAME##*/}" = "master" ]; then
131+
tag=latest
132+
else
133+
tag=build-test
134+
fi
135+
echo "docker_tag=${tag}" >> $GITHUB_OUTPUT
136+
-
137+
name: Download digests
138+
uses: actions/download-artifact@v4
139+
with:
140+
path: ${{ runner.temp }}/digests
141+
pattern: digests-*
142+
merge-multiple: true
143+
-
144+
name: Set up Docker Buildx
145+
uses: docker/setup-buildx-action@v3
146+
-
147+
name: Login to DockerHub
148+
uses: docker/login-action@v3
149+
with:
150+
username: ${{ secrets.DOCKERHUB_USERNAME }}
151+
password: ${{ secrets.DOCKERHUB_TOKEN }}
152+
-
153+
name: Create manifest list and push
154+
working-directory: ${{ runner.temp }}/digests
155+
run: |
156+
for i in *; do
157+
docker buildx imagetools create -t "tunathu/$i:${{ steps.docker_tag.outputs.docker_tag }}" \
158+
$(printf "$i@sha256:%s " $(ls $i))
159+
done
160+
161+
- name: Inspect images
162+
working-directory: ${{ runner.temp }}/digests
163+
run: |
164+
for i in *; do
165+
docker buildx imagetools inspect "tunathu/$i:${{ steps.docker_tag.outputs.docker_tag }}"
166+
done

0 commit comments

Comments
 (0)