Skip to content

Commit e51de71

Browse files
author
Moaad Khamlich
committed
ENH: split Docker workflow into separate AMD64/ARM64 builds with manifest merge
1 parent ff018cd commit e51de71

File tree

1 file changed

+91
-6
lines changed

1 file changed

+91
-6
lines changed

.github/workflows/docker-publish.yml

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,61 @@ env:
99
IMAGE_NAME: ithacafv/ithaca-fv
1010

1111
jobs:
12-
build-ithaca:
12+
build-amd64:
1313
runs-on: ubuntu-latest
14+
outputs:
15+
digest: ${{ steps.build.outputs.digest }}
16+
metadata: ${{ steps.meta.outputs.json }}
1417

1518
steps:
1619
- name: Checkout repository
1720
uses: actions/checkout@v4
1821

19-
- name: Set up QEMU
20-
uses: docker/setup-qemu-action@v3
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log into registry ${{ env.REGISTRY }}
26+
if: github.event_name != 'pull_request'
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Extract metadata for ITHACA-FV image
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
tags: |
39+
type=ref,event=branch
40+
type=ref,event=pr
41+
type=semver,pattern={{version}}
42+
type=semver,pattern={{major}}.{{minor}}
43+
type=raw,value=latest,enable={{is_default_branch}}
44+
45+
- name: Build and push AMD64 image
46+
id: build
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: ./dockerfiles/OF2412
50+
platforms: linux/amd64
51+
push: ${{ github.event_name != 'pull_request' }}
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
57+
58+
build-arm64:
59+
runs-on: ubuntu-24.04-arm
60+
outputs:
61+
digest: ${{ steps.build.outputs.digest }}
62+
metadata: ${{ steps.meta.outputs.json }}
63+
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
2167

2268
- name: Set up Docker Buildx
2369
uses: docker/setup-buildx-action@v3
@@ -42,13 +88,52 @@ jobs:
4288
type=semver,pattern={{major}}.{{minor}}
4389
type=raw,value=latest,enable={{is_default_branch}}
4490
45-
- name: Build and push ITHACA-FV image
91+
- name: Build and push ARM64 image
92+
id: build
4693
uses: docker/build-push-action@v5
4794
with:
4895
context: ./dockerfiles/OF2412
49-
platforms: linux/amd64,linux/arm64
96+
platforms: linux/arm64
5097
push: ${{ github.event_name != 'pull_request' }}
5198
tags: ${{ steps.meta.outputs.tags }}
5299
labels: ${{ steps.meta.outputs.labels }}
53100
cache-from: type=gha
54-
cache-to: type=gha,mode=max
101+
cache-to: type=gha,mode=max
102+
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
103+
104+
merge:
105+
runs-on: ubuntu-latest
106+
needs:
107+
- build-amd64
108+
- build-arm64
109+
steps:
110+
- name: Set up Docker Buildx
111+
uses: docker/setup-buildx-action@v3
112+
113+
- name: Log into registry ${{ env.REGISTRY }}
114+
uses: docker/login-action@v3
115+
with:
116+
registry: ${{ env.REGISTRY }}
117+
username: ${{ secrets.DOCKER_USERNAME }}
118+
password: ${{ secrets.DOCKER_PASSWORD }}
119+
120+
- name: Extract metadata for ITHACA-FV image
121+
id: meta
122+
uses: docker/metadata-action@v5
123+
with:
124+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
125+
tags: |
126+
type=ref,event=branch
127+
type=ref,event=pr
128+
type=semver,pattern={{version}}
129+
type=semver,pattern={{major}}.{{minor}}
130+
type=raw,value=latest,enable={{is_default_branch}}
131+
132+
- name: Create and push manifest list
133+
working-directory: /tmp
134+
run: |
135+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
136+
${{ needs.build-amd64.outputs.digest }} \
137+
${{ needs.build-arm64.outputs.digest }}
138+
env:
139+
DOCKER_METADATA_OUTPUT_JSON: ${{ needs.build-amd64.outputs.metadata }}

0 commit comments

Comments
 (0)