Skip to content

Commit 8ae494e

Browse files
committed
GH actions: split qemu emulated docker builds to native architecture builds
1 parent 82041ff commit 8ae494e

File tree

1 file changed

+52
-12
lines changed

1 file changed

+52
-12
lines changed

.github/workflows/docker.yml

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,64 @@ jobs:
5959
tags: |
6060
${{ env.IMAGE_NAME }}:latest-${{ github.ref_name }}
6161
62-
release:
62+
build-matrix:
6363
if: github.event_name == 'release'
64-
runs-on: ubuntu-latest
64+
runs-on: ${{ matrix.runner }}
65+
strategy:
66+
matrix:
67+
include:
68+
- arch: amd64
69+
platform: linux/amd64
70+
runner: ubuntu-latest
71+
- arch: arm64
72+
platform: linux/arm64
73+
runner: ubuntu-latest-arm64
6574
steps:
66-
- *checkout-step
67-
68-
- *setup-qemu-step
69-
70-
- *login-step
75+
- name: Check out repository
76+
uses: actions/checkout@v4
7177

72-
- *setup-buildx-step
78+
- name: Login to Docker Hub
79+
uses: docker/login-action@v3
80+
with:
81+
username: ${{ secrets.DOCKERHUB_USERNAME }}
82+
password: ${{ secrets.DOCKERHUB_TOKEN }}
83+
84+
- name: Set up Docker Buildx
85+
uses: docker/setup-buildx-action@v3
7386

74-
- name: Build and push release image
87+
- name: Build and push architecture-specific image
7588
uses: docker/build-push-action@v6
7689
with:
7790
context: .
7891
push: true
79-
platforms: linux/amd64,linux/arm64,linux/arm/v7
92+
platforms: ${{ matrix.platform }}
93+
cache-from: type=gha
94+
cache-to: type=gha,mode=max
8095
tags: |
81-
${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
82-
${{ env.IMAGE_NAME }}:latest
96+
${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}-${{ matrix.arch }}
97+
${{ env.IMAGE_NAME }}:latest-${{ matrix.arch }}
98+
99+
create-manifest:
100+
if: github.event_name == 'release'
101+
needs: build-matrix
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Login to Docker Hub
105+
uses: docker/login-action@v3
106+
with:
107+
username: ${{ secrets.DOCKERHUB_USERNAME }}
108+
password: ${{ secrets.DOCKERHUB_TOKEN }}
109+
110+
- name: Create and push multi-arch manifest for release tag
111+
run: |
112+
docker manifest create ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} \
113+
--amend ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}-amd64 \
114+
--amend ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}-arm64
115+
docker manifest push ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
116+
117+
- name: Create and push multi-arch manifest for latest tag
118+
run: |
119+
docker manifest create ${{ env.IMAGE_NAME }}:latest \
120+
--amend ${{ env.IMAGE_NAME }}:latest-amd64 \
121+
--amend ${{ env.IMAGE_NAME }}:latest-arm64
122+
docker manifest push ${{ env.IMAGE_NAME }}:latest

0 commit comments

Comments
 (0)