Skip to content

Commit a81a861

Browse files
committed
ci: PLT-859: migrate to arm64 runner for image builds
1 parent 0cc7ed4 commit a81a861

File tree

2 files changed

+161
-53
lines changed

2 files changed

+161
-53
lines changed

.github/workflows/docker-build-ontop.yml

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,25 @@ env:
4343
IMAGE_NAME: "${{ vars.DOCKERHUB_ORG }}/label-studio"
4444

4545
jobs:
46-
docker_build_and_push:
47-
name: "Docker image"
46+
docker_build:
47+
name: "Docker image (${{ matrix.platform }})"
4848
timeout-minutes: 90
49-
runs-on: ubuntu-latest
49+
runs-on: ${{ matrix.runner }}
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
include:
54+
- platform: linux/amd64
55+
runner: ubuntu-latest
56+
- platform: linux/arm64
57+
runner: ubuntu-24.04-arm
5058
steps:
5159
- uses: hmarr/[email protected]
5260

53-
- name: Check user's membership
54-
uses: actions/github-script@v7
55-
id: actor-membership
56-
env:
57-
ACTOR: ${{ github.actor }}
58-
with:
59-
github-token: ${{ secrets.GIT_PAT }}
60-
script: |
61-
const { repo, owner } = context.repo;
62-
const actor = process.env.ACTOR;
63-
const { data: membership } = await github.rest.orgs.getMembershipForUser({
64-
org: owner,
65-
username: actor,
66-
});
67-
core.setOutput("state", membership.state);
68-
core.setOutput("active", membership.state == "active");
61+
- name: Prepare
62+
run: |
63+
platform=${{ matrix.platform }}
64+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
6965
7066
- name: Checkout
7167
id: checkout
@@ -75,13 +71,6 @@ jobs:
7571
ref: ${{ inputs.ref }}
7672
fetch-depth: 0
7773

78-
- name: Calculate Docker tags
79-
id: calculate-docker-tags
80-
uses: actions/github-script@v7
81-
with:
82-
script: |
83-
core.setOutput('docker-tags', `${{ inputs.tags }}`.split(",").join("\n"))
84-
8574
- name: Edit Dockerfile
8675
env:
8776
BASE_DOCKER_IMAGE_VERSION: ${{ inputs.base_docker_image_version }}
@@ -90,9 +79,6 @@ jobs:
9079
sed -i "s#^FROM .*#FROM ${IMAGE_NAME}:${BASE_DOCKER_IMAGE_VERSION}#g" "${DOCKERFILE_PATH}"
9180
cat "${DOCKERFILE_PATH}"
9281
93-
- name: Set up QEMU
94-
uses: docker/setup-qemu-action@v3
95-
9682
- name: Set up Docker Buildx
9783
uses: docker/[email protected]
9884

@@ -102,27 +88,83 @@ jobs:
10288
username: ${{ vars.DOCKERHUB_USERNAME }}
10389
password: ${{ secrets.DOCKERHUB_TOKEN }}
10490

105-
- name: Extract Docker metadata
91+
- name: Docker meta
10692
id: meta
10793
uses: docker/metadata-action@v5
10894
with:
10995
images: ${{ env.IMAGE_NAME }}
110-
labels: |
111-
org.opencontainers.image.revision=${{ steps.checkout.outputs.commit }}
112-
tags: |
113-
${{ steps.calculate-docker-tags.outputs.docker-tags }}
11496

115-
- name: Push Docker image
97+
- name: Push Docker image (${{ matrix.platform }})
11698
uses: docker/[email protected]
11799
id: docker_build_and_push
118100
with:
119101
context: .
120102
file: ${{ inputs.dockerfile_path }}
121-
platforms: linux/amd64,linux/arm64
122-
push: ${{ steps.actor-membership.outputs.active }}
103+
platforms: ${{ matrix.platform }}
123104
sbom: true
124105
provenance: true
125-
tags: ${{ steps.meta.outputs.tags }}
106+
tags: ${{ env.IMAGE_NAME }}
126107
labels: ${{ steps.meta.outputs.labels }}
127108
cache-from: type=gha
128-
cache-to: type=gha,mode=max
109+
cache-to: type=gha,mode=min
110+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
111+
112+
- name: Export digest
113+
run: |
114+
mkdir -p ${{ runner.temp }}/digests
115+
digest="${{ steps.docker_build_and_push.outputs.digest }}"
116+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
117+
118+
- name: Upload digest
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: digests-${{ env.PLATFORM_PAIR }}
122+
path: ${{ runner.temp }}/digests/*
123+
if-no-files-found: error
124+
retention-days: 1
125+
126+
merge_docker_manifest:
127+
runs-on: ubuntu-latest
128+
needs:
129+
- docker_build
130+
steps:
131+
- name: Download digests
132+
uses: actions/download-artifact@v4
133+
with:
134+
path: ${{ runner.temp }}/digests
135+
pattern: digests-*
136+
merge-multiple: true
137+
138+
- name: Login to Docker Hub
139+
uses: docker/login-action@v3
140+
with:
141+
username: ${{ vars.DOCKERHUB_USERNAME }}
142+
password: ${{ secrets.DOCKERHUB_TOKEN }}
143+
144+
- name: Set up Docker Buildx
145+
uses: docker/setup-buildx-action@v3
146+
147+
- name: Calculate Docker tags
148+
id: calculate-docker-tags
149+
uses: actions/github-script@v7
150+
with:
151+
script: |
152+
core.setOutput('docker-tags', `${{ inputs.tags }}`.split(",").join("\n"))
153+
154+
- name: Extract Docker metadata
155+
id: meta
156+
uses: docker/metadata-action@v5
157+
with:
158+
images: ${{ env.IMAGE_NAME }}
159+
tags: |
160+
${{ steps.calculate-docker-tags.outputs.docker-tags }}
161+
162+
- name: Create manifest list and push
163+
working-directory: ${{ runner.temp }}/digests
164+
run: |
165+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
166+
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
167+
168+
- name: Inspect image
169+
run: |
170+
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

.github/workflows/docker-release-promote.yml

Lines changed: 80 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,25 @@ env:
1717
DOCKER_IMAGE_TAG_CHECK_NAME: "Docker image tag"
1818
IMAGE_NAME: "${{ vars.DOCKERHUB_ORG }}/label-studio"
1919
RELEASE_DOCKERFILE: "Dockerfile.release"
20-
PREFLIGHT_REPO: "quay.io/opdev/preflight:stable"
21-
DOCKER_CONFIG_PATH: "/home/runner/.docker/config.json"
2220
LAUNCHDARKLY_DOWNLOAD_PATH: "feature_flags.json"
2321

2422
jobs:
2523
docker_release_retag:
26-
name: "Docker image"
24+
name: "Docker image (${{ matrix.platform }})"
2725
timeout-minutes: 90
28-
runs-on: ubuntu-latest
26+
runs-on: ${{ matrix.runner }}
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- platform: linux/amd64
32+
runner: ubuntu-latest
33+
- platform: linux/arm64
34+
runner: ubuntu-24.04-arm
2935
outputs:
3036
image_version: ${{ steps.get_info.outputs.image_version }}
37+
ubuntu_tags: ${{ steps.generate-tags.outputs.ubuntu-tags }}
38+
sha: ${{ steps.get_info.outputs.sha }}
3139
steps:
3240
- uses: hmarr/[email protected]
3341

@@ -134,9 +142,6 @@ jobs:
134142
python3 $(pwd)/label_studio/core/version.py
135143
cat $(pwd)/label_studio/core/version_.py
136144
137-
- name: Set up QEMU
138-
uses: docker/setup-qemu-action@v3
139-
140145
- name: Set up Docker Buildx
141146
uses: docker/[email protected]
142147

@@ -146,6 +151,11 @@ jobs:
146151
username: ${{ vars.DOCKERHUB_USERNAME }}
147152
password: ${{ secrets.DOCKERHUB_TOKEN }}
148153

154+
- name: Prepare
155+
run: |
156+
platform=${{ matrix.platform }}
157+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
158+
149159
- name: Prepare Release Dockerfile
150160
id: release_dockerfile
151161
env:
@@ -173,26 +183,82 @@ jobs:
173183
uses: docker/metadata-action@v5
174184
with:
175185
images: ${{ env.IMAGE_NAME }}
176-
labels: |
177-
org.opencontainers.image.revision=${{ steps.get_info.outputs.sha }}
178-
tags: |
179-
${{ steps.generate-tags.outputs.ubuntu-tags }}
180186

181-
- name: Build and Push Release Ubuntu Docker image
187+
- name: Build and Push Release Ubuntu Docker image (${{ matrix.platform }})
182188
uses: docker/[email protected]
183189
id: docker_build
184190
with:
185191
context: ${{ steps.release_dockerfile.outputs.release_dir }}
186192
file: ${{ steps.release_dockerfile.outputs.release_dir }}/${{ env.RELEASE_DOCKERFILE }}
187-
push: true
188193
sbom: true
189194
provenance: true
190195
tags: ${{ steps.meta.outputs.tags }}
191196
labels: ${{ steps.meta.outputs.labels }}
192197
cache-from: type=gha
193198
cache-to: type=gha,mode=max
194-
platforms: linux/amd64,linux/arm64
199+
platforms: ${{ matrix.platform }}
200+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
201+
202+
- name: Export digest
203+
run: |
204+
mkdir -p ${{ runner.temp }}/digests
205+
digest="${{ steps.docker_build.outputs.digest }}"
206+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
207+
208+
- name: Upload digest
209+
uses: actions/upload-artifact@v4
210+
with:
211+
name: digests-${{ env.PLATFORM_PAIR }}
212+
path: ${{ runner.temp }}/digests/*
213+
if-no-files-found: error
214+
retention-days: 1
215+
216+
merge_docker_manifest:
217+
runs-on: ubuntu-latest
218+
needs:
219+
- docker_release_retag
220+
steps:
221+
- name: Download digests
222+
uses: actions/download-artifact@v4
223+
with:
224+
path: ${{ runner.temp }}/digests
225+
pattern: digests-*
226+
merge-multiple: true
227+
228+
- name: Login to Docker Hub
229+
uses: docker/login-action@v3
230+
with:
231+
username: ${{ vars.DOCKERHUB_USERNAME }}
232+
password: ${{ secrets.DOCKERHUB_TOKEN }}
233+
234+
- name: Set up Docker Buildx
235+
uses: docker/setup-buildx-action@v3
236+
237+
- name: Extract Docker metadata
238+
id: meta
239+
uses: docker/metadata-action@v5
240+
with:
241+
images: ${{ env.IMAGE_NAME }}
242+
labels: |
243+
org.opencontainers.image.revision=${{ needs.docker_release_retag.outputs.sha }}
244+
tags: |
245+
${{ steps.generate-tags.outputs.ubuntu-tags }}
246+
247+
- name: Create manifest list and push
248+
working-directory: ${{ runner.temp }}/digests
249+
run: |
250+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
251+
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
195252
253+
- name: Inspect image
254+
run: |
255+
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
256+
257+
copy_static_files:
258+
name: "Copy compiled static from built Docker image"
259+
runs-on: ubuntu-latest
260+
needs: [docker_release_retag, merge_docker_manifest]
261+
steps:
196262
- name: Copy compiled static from builded Docker image
197263
run: |
198264
# Usually it takes 10-20 sec so the image becomes available

0 commit comments

Comments
 (0)