Skip to content

Commit 31b48c4

Browse files
committed
Use separate ARM64 runner for faster ARM64 Docker builds
1 parent 0fc69f6 commit 31b48c4

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

.github/workflows/docker-build.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,24 @@ env:
3030
IMAGE_SLUG: ${{ github.repository }}
3131

3232
jobs:
33-
# Push image to GitHub Container Registry.
33+
# Generate shared tags for both architectures
3434
# The image tag pattern is:
3535
# for pull-requests: <PATCH_VERSION>-<DATE>-<PR_NUMBER>, eg: 1.35.2-20210125-25
3636
# for tags: <TAG>
3737
# for `master` branch: latest,<PATCH_VERSION>-latest,<MINOR_VERSION>-latest,<MAJOR_VERSION>-latest,<PATCH_VERSION>-<DATE>-<SHA>
3838
# for `development` branch: development,<MAJOR_VERSION>-development,<PATCH_VERSION>-<DATE>-<SHA>
3939
# for releases: release,<PATCH_VERSION>-release,<MINOR_VERSION>-release,<MAJOR_VERSION>-release,<PATCH_VERSION>-<DATE>-<SHA>
4040
# Version is parsed from package.json
41-
push:
41+
generate-tags:
4242
runs-on: ubuntu-latest
4343
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'release'
44+
outputs:
45+
registry-tags: ${{ steps.generate.outputs.REGISTRY_TAGS }}
46+
image-id: ${{ steps.generate.outputs.IMAGE_ID }}
4447
steps:
4548
- name: Checkout
4649
uses: actions/checkout@v3
4750

48-
- name: Set up Docker Buildx
49-
uses: docker/setup-buildx-action@v3
50-
with:
51-
platforms: linux/amd64,linux/arm64
52-
5351
- name: Generate tags
5452
id: generate
5553
run: |
@@ -112,22 +110,47 @@ jobs:
112110
echo "REGISTRY_TAGS_PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
113111
echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_OUTPUT
114112
113+
# Build and push AMD64 image on x64 runner
114+
build-amd64:
115+
needs: generate-tags
116+
runs-on: ubuntu-latest # x64 runner for native AMD64 builds
117+
steps:
118+
- name: Checkout
119+
uses: actions/checkout@v3
120+
121+
- name: Set up Docker Buildx
122+
uses: docker/setup-buildx-action@v3
123+
115124
- name: Login to GHCR
116125
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} --password-stdin ghcr.io
117126

118127
- name: Docker buildx build and push (AMD64)
119128
run: |
120129
docker buildx build \
121130
--platform linux/amd64 \
122-
${{ steps.generate.outputs.REGISTRY_TAGS }} \
131+
${{ needs.generate-tags.outputs.registry-tags }} \
123132
--push \
124133
--no-cache \
125134
.
126135
136+
# Build and push ARM64 image on ARM64 runner
137+
build-arm64:
138+
needs: generate-tags
139+
runs-on: ubuntu-24.04-arm # ARM64 runner for native ARM64 builds
140+
steps:
141+
- name: Checkout
142+
uses: actions/checkout@v3
143+
144+
- name: Set up Docker Buildx
145+
uses: docker/setup-buildx-action@v3
146+
147+
- name: Login to GHCR
148+
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} --password-stdin ghcr.io
149+
127150
- name: Docker buildx build and push (ARM64)
128151
run: |
129152
# Generate ARM64-specific tags by adding -arm64 suffix
130-
ARM64_TAGS=${{ steps.generate.outputs.REGISTRY_TAGS }}-arm64
153+
ARM64_TAGS=${{ needs.generate-tags.outputs.registry-tags }}-arm64
131154
docker buildx build \
132155
--platform linux/arm64 \
133156
${ARM64_TAGS} \

0 commit comments

Comments
 (0)