2727 runs-on : ubuntu-latest
2828 needs : [test]
2929 outputs :
30- matrix : ${{ steps.set-matrix.outputs.matrix }}
30+ version_matrix : ${{ steps.set-matrix.outputs.matrix }}
31+ arch_matrix : ${{ steps.set-matrix.outputs.arch_matrix }}
3132 steps :
3233 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3334 with :
@@ -42,61 +43,84 @@ jobs:
4243 uv run dpn $FORCE build-matrix --event ${{ github.event_name }}
4344
4445
45- deploy :
46- name : ${{ matrix.key }}
47- runs-on : ubuntu-latest
48- if : needs.generate-matrix.outputs.matrix != ''
46+ build-arch :
47+ name : ${{ matrix.key }} (${{ matrix.arch }})
48+ runs-on : ${{ matrix.runner }}
49+ if : needs.generate-matrix.outputs.arch_matrix != ''
4950 needs : [generate-matrix]
5051 strategy :
51- matrix : ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
52+ fail-fast : false
53+ matrix : ${{ fromJSON(needs.generate-matrix.outputs.arch_matrix) }}
5254 steps :
5355 # Setup
5456 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
5557 - uses : astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
5658 with :
5759 enable-cache : true
5860 - name : Generate Dockerfile from config
59- run : uv run dpn dockerfile --context '${{ toJSON(matrix) }}'
60- - name : Set up QEMU
61- uses : docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
61+ run : |
62+ context="$(echo '${{ toJSON(matrix) }}' | jq -c '{key, python, python_canonical, python_image, nodejs, nodejs_canonical, distro, platforms, digest}')"
63+ uv run dpn dockerfile --context "${context}"
6264 - name : Set up Docker Buildx
6365 uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
64- - name : Login to Docker Hub
65- uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
66- with :
67- username : ${{ secrets.DOCKERHUB_USERNAME }}
68- password : ${{ secrets.DOCKERHUB_TOKEN }}
6966
7067 # Build
7168 - name : Build image
7269 uses : docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
7370 with :
7471 context : .
7572 file : dockerfiles/${{ matrix.key }}.Dockerfile
73+ platforms : ${{ matrix.platform }}
7674 load : true
77- tags : ${{ env.IMAGE_NAME }}:${{ matrix.key }}
75+ tags : ${{ env.IMAGE_NAME }}:${{ matrix.key }}-${{ matrix.arch }}
7876
7977 # Test
8078 - name : Run smoke tests
8179 run : |
82- 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"
80+ docker run --rm ${{ env.IMAGE_NAME }}:${{ matrix.key }}-${{ matrix.arch }} sh -c "node --version && npm --version && yarn --version && python --version && pip --version && pipenv --version && poetry --version && uv --version"
8381
84- # Push image
82+ # Push
83+ - name : Login to Docker Hub
84+ uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
85+ with :
86+ username : ${{ secrets.DOCKERHUB_USERNAME }}
87+ password : ${{ secrets.DOCKERHUB_TOKEN }}
8588 - name : Push image
86- uses : docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
87- id : build-and-push
89+ run : docker push "${IMAGE_NAME}:${{ matrix.key }}-${{ matrix.arch }}"
90+
91+ deploy :
92+ name : Publish ${{ matrix.key }}
93+ runs-on : ubuntu-latest
94+ if : needs.generate-matrix.outputs.version_matrix != ''
95+ needs : [generate-matrix, build-arch]
96+ strategy :
97+ fail-fast : false
98+ matrix : ${{ fromJSON(needs.generate-matrix.outputs.version_matrix) }}
99+ steps :
100+ - name : Create local multi-arch manifest
101+ run : |
102+ refs=("${IMAGE_NAME}:${{ matrix.key }}-amd64")
103+ if echo '${{ toJSON(matrix.platforms) }}' | jq -e '.[] == "linux/arm64"' > /dev/null; then
104+ refs+=("${IMAGE_NAME}:${{ matrix.key }}-arm64")
105+ fi
106+ docker manifest create "${IMAGE_NAME}:${{ matrix.key }}" "${refs[@]}"
107+
108+ - name : Login to Docker Hub
109+ uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
88110 with :
89- context : .
90- file : dockerfiles/${{ matrix.key }}.Dockerfile
91- platforms : ${{ join(matrix.platforms) }}
92- push : true
93- tags : ${{ env.IMAGE_NAME }}:${{ matrix.key }}
111+ username : ${{ secrets.DOCKERHUB_USERNAME }}
112+ password : ${{ secrets.DOCKERHUB_TOKEN }}
113+
114+ - name : Push multi-arch manifest
115+ run : docker manifest push "${IMAGE_NAME}:${{ matrix.key }}"
116+
117+ - name : Set up Docker Buildx
118+ uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
94119
95- # Store build context
96120 - name : Add digest to build context
97121 run : |
98122 mkdir builds/
99- digest="${{ steps.build-and-push.outputs.digest }}"
123+ digest="$(docker buildx imagetools inspect "${IMAGE_NAME}:${{ matrix.key }}" | awk '/^Digest:/ {print $2}') "
100124 echo '${{ toJSON(matrix) }}' | jq --arg digest "$digest" '. +={"digest": $digest}' >> "builds/${{ matrix.key }}.json"
101125
102126 - name : Upload build context
0 commit comments