1+ # Multi-platform Docker build using native runners
2+ # Reference: https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
13name : Weaver Docker Generator
24on :
35 push :
@@ -11,10 +13,19 @@ permissions:
1113 contents : read
1214env :
1315 TEST_WEAVER_TAG : otel/weaver:test
16+ REGISTRY_IMAGE : otel/weaver
1417jobs :
15- make-docker-image :
16- name : Docker Image
17- runs-on : ubuntu-latest
18+ build :
19+ name : Build ${{ matrix.platform }}
20+ runs-on : ${{ matrix.runner }}
21+ strategy :
22+ fail-fast : false
23+ matrix :
24+ include :
25+ - platform : linux/amd64
26+ runner : ubuntu-latest
27+ - platform : linux/arm64
28+ runner : ubuntu-24.04-arm
1829 steps :
1930 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2031 - name : Setup Node.js
@@ -23,38 +34,84 @@ jobs:
2334 node-version-file : ' .nvmrc'
2435 cache : ' npm'
2536 cache-dependency-path : ui/package-lock.json
26- - name : Set up QEMU
27- uses : docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
2837 - name : Set up Docker Buildx
2938 uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
3039 - name : Extract metadata (tags, labels) for Docker
3140 id : meta
3241 uses : docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
3342 with :
34- images : otel/weaver
43+ images : ${{ env.REGISTRY_IMAGE }}
3544 - name : Build test image
3645 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
3746 with :
38- push : false
39- load : true
40- tags : ${{ env.TEST_WEAVER_TAG }}
41- labels : ${{ steps.meta.outputs.labels }}
47+ push : false
48+ load : true
49+ platforms : ${{ matrix.platform }}
50+ tags : ${{ env.TEST_WEAVER_TAG }}
51+ labels : ${{ steps.meta.outputs.labels }}
4252 - name : Test
4353 run : |
44- docker run --rm ${{ env.TEST_WEAVER_TAG }} --help
54+ docker run --rm ${{ env.TEST_WEAVER_TAG }} --help
4555 - name : Log in to Docker Hub
4656 uses : docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
4757 if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
4858 with :
4959 username : ${{ secrets.DOCKER_USERNAME }}
5060 password : ${{ secrets.DOCKER_PASSWORD }}
51- - name : Build and push
61+ - name : Build and push by digest
62+ id : build
5263 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
5364 if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
5465 with :
55- push : true
56- platforms : linux/amd64,linux/arm64
66+ platforms : ${{ matrix.platform }}
5767 provenance : mode=max
5868 sbom : true
59- tags : ${{ steps.meta.outputs.tags }}
6069 labels : ${{ steps.meta.outputs.labels }}
70+ outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
71+ - name : Export digest
72+ if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
73+ run : |
74+ mkdir -p /tmp/digests
75+ digest="${{ steps.build.outputs.digest }}"
76+ touch "/tmp/digests/${digest#sha256:}"
77+ - name : Upload digest
78+ if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
79+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
80+ with :
81+ name : digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
82+ path : /tmp/digests/*
83+ if-no-files-found : error
84+ retention-days : 1
85+
86+ merge :
87+ name : Merge manifests
88+ runs-on : ubuntu-latest
89+ if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
90+ needs : build
91+ steps :
92+ - name : Download digests
93+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
94+ with :
95+ path : /tmp/digests
96+ pattern : digests-*
97+ merge-multiple : true
98+ - name : Set up Docker Buildx
99+ uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
100+ - name : Extract metadata (tags, labels) for Docker
101+ id : meta
102+ uses : docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
103+ with :
104+ images : ${{ env.REGISTRY_IMAGE }}
105+ - name : Log in to Docker Hub
106+ uses : docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
107+ with :
108+ username : ${{ secrets.DOCKER_USERNAME }}
109+ password : ${{ secrets.DOCKER_PASSWORD }}
110+ - name : Create manifest list and push
111+ working-directory : /tmp/digests
112+ run : |
113+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
114+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
115+ - name : Inspect image
116+ run : |
117+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments