2222 runs-on : ubuntu-latest
2323 needs : [test]
2424 outputs :
25- matrix : ${{ steps.set-matrix.outputs.matrix }}
25+ version_matrix : ${{ steps.set-matrix.outputs.matrix }}
26+ arch_matrix : ${{ steps.set-matrix.outputs.arch_matrix }}
2627 steps :
2728 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2829 with :
@@ -37,23 +38,24 @@ jobs:
3738 uv run dpn $FORCE build-matrix --event ${{ github.event_name }}
3839
3940
40- deploy :
41- name : ${{ matrix.key }}
42- runs-on : ubuntu-latest
43- if : needs.generate-matrix.outputs.matrix != ''
41+ build-arch :
42+ name : ${{ matrix.key }} (${{ matrix.arch }})
43+ runs-on : ${{ matrix.runner }}
44+ if : needs.generate-matrix.outputs.arch_matrix != ''
4445 needs : [generate-matrix]
4546 strategy :
46- matrix : ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
47+ fail-fast : false
48+ matrix : ${{ fromJSON(needs.generate-matrix.outputs.arch_matrix) }}
4749 steps :
4850 # Setup
4951 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
5052 - uses : astral-sh/setup-uv@e06108dd0aef18192324c70427afc47652e63a82 # v7
5153 with :
5254 enable-cache : true
5355 - name : Generate Dockerfile from config
54- run : uv run dpn dockerfile --context '${{ toJSON(matrix) }}'
55- - name : Set up QEMU
56- uses : docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
56+ run : |
57+ context="$(echo '${{ toJSON(matrix) }}' | jq -c '{key, python, python_canonical, python_image, nodejs, nodejs_canonical, distro, platforms, digest}')"
58+ uv run dpn dockerfile --context "${context}"
5759 - name : Set up Docker Buildx
5860 uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
5961 - name : Login to Docker Hub
@@ -62,36 +64,51 @@ jobs:
6264 username : ${{ secrets.DOCKERHUB_USERNAME }}
6365 password : ${{ secrets.DOCKERHUB_TOKEN }}
6466
65- # Build
67+ # Build and push
6668 - name : Build image
69+ id : build-and-push
6770 uses : docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
6871 with :
6972 context : .
7073 file : dockerfiles/${{ matrix.key }}.Dockerfile
71- load : true
72- tags : ${{ env.IMAGE_NAME }}:${{ matrix.key }}
74+ platforms : ${{ matrix.platform }}
75+ push : true
76+ tags : ${{ env.IMAGE_NAME }}:${{ matrix.key }}-${{ matrix.arch }}
7377
7478 # Test
7579 - name : Run smoke tests
7680 run : |
77- docker run --rm ${{ env.IMAGE_NAME }}: ${{ matrix.key }} sh -c "node --version && npm --version && yarn --version && python --version && pip --version && pipenv --version && poetry --version && uv --version"
81+ docker run --rm ${{ env.IMAGE_NAME }}@ ${{ steps.build-and-push.outputs.digest }} sh -c "node --version && npm --version && yarn --version && python --version && pip --version && pipenv --version && poetry --version && uv --version"
7882
79- # Push image
80- - name : Push image
81- uses : docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
82- id : build-and-push
83+ deploy :
84+ name : Publish ${{ matrix.key }}
85+ runs-on : ubuntu-latest
86+ if : needs.generate-matrix.outputs.version_matrix != ''
87+ needs : [generate-matrix, build-arch]
88+ strategy :
89+ fail-fast : false
90+ matrix : ${{ fromJSON(needs.generate-matrix.outputs.version_matrix) }}
91+ steps :
92+ - name : Set up Docker Buildx
93+ uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
94+ - name : Login to Docker Hub
95+ uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
8396 with :
84- context : .
85- file : dockerfiles/${{ matrix.key }}.Dockerfile
86- platforms : ${{ join(matrix.platforms) }}
87- push : true
88- tags : ${{ env.IMAGE_NAME }}:${{ matrix.key }}
97+ username : ${{ secrets.DOCKERHUB_USERNAME }}
98+ password : ${{ secrets.DOCKERHUB_TOKEN }}
99+
100+ - name : Publish multi-arch manifest
101+ run : |
102+ tags=("${IMAGE_NAME}:${{ matrix.key }}-amd64")
103+ if echo '${{ toJSON(matrix.platforms) }}' | jq -e '.[] == "linux/arm64"' > /dev/null; then
104+ tags+=("${IMAGE_NAME}:${{ matrix.key }}-arm64")
105+ fi
106+ docker buildx imagetools create --tag "${IMAGE_NAME}:${{ matrix.key }}" "${tags[@]}"
89107
90- # Store build context
91108 - name : Add digest to build context
92109 run : |
93110 mkdir builds/
94- digest="${{ steps.build-and-push.outputs.digest }}"
111+ digest="$(docker buildx imagetools inspect "${IMAGE_NAME}:${{ matrix.key }}" | awk '/^Digest:/ {print $2}') "
95112 echo '${{ toJSON(matrix) }}' | jq --arg digest "$digest" '. +={"digest": $digest}' >> "builds/${{ matrix.key }}.json"
96113
97114 - name : Upload build context
0 commit comments