@@ -231,11 +231,16 @@ jobs:
231231 retention-days : 30
232232
233233 docker_build :
234+ name : docker_build (${{ matrix.platform }}, ${{ matrix.variant }})
234235 runs-on : ubuntu-latest
235236 strategy :
236237 fail-fast : false
237238 matrix :
238239 include :
240+ - platform : linux/amd64
241+ variant : minimal
242+ tag_suffix : -linux-amd64
243+ export : true
239244 - platform : linux/arm/v7
240245 variant : minimal
241246 tag_suffix : -linux-arm-v7
@@ -261,6 +266,7 @@ jobs:
261266
262267 recipe_hash="${{ hashFiles('Dockerfile', '.cargo/**', 'Cargo.toml', 'Cargo.lock', 'build.rs', 'scripts/**', 'sqlpage/**', 'frontend/src/**', 'package.json', 'package-lock.json') }}"
263268 {
269+ echo "artifact=sqlpage-${ref_scope}${{ matrix.tag_suffix }}-hurl-${recipe_hash}"
264270 echo "current=sqlpage-${ref_scope}${{ matrix.tag_suffix }}-${recipe_hash}"
265271 echo "main=sqlpage-main${{ matrix.tag_suffix }}-${recipe_hash}"
266272 } >> "$GITHUB_OUTPUT"
@@ -273,6 +279,7 @@ jobs:
273279 labels : |
274280 org.opencontainers.image.created=1970-01-01T00:00:00Z
275281 - name : Set up QEMU
282+ if : matrix.platform != 'linux/amd64'
276283 uses : docker/setup-qemu-action@v4
277284 - name : Set up Docker Buildx
278285 uses : docker/setup-buildx-action@v4
@@ -282,85 +289,16 @@ jobs:
282289 with :
283290 username : ${{ env.REGISTRY_USERNAME }}
284291 password : ${{ secrets.DOCKERHUB_TOKEN }}
285- - name : Build and push by digest
286- id : build
292+ # The Hurl examples run against a real image, so the one platform they use
293+ # is also exported as a tarball instead of only being pushed by digest.
294+ - name : Build image for Hurl examples
295+ if : matrix.export
287296 uses : docker/build-push-action@v7
288297 with :
289- # Use BuildKit's Git context instead of the mutable runner workspace.
290- # The dependency cache should be keyed by committed source, not by a
291- # per-job local context stream.
292298 context : " {{defaultContext}}"
293299 platforms : ${{ matrix.platform }}
294300 target : ${{ matrix.variant }}
295301 labels : ${{ steps.meta.outputs.labels }}
296- push : ${{ github.event_name != 'pull_request' }}
297- tags : ${{ steps.meta.outputs.tags }}
298- cache-from : |
299- type=gha,scope=${{ steps.cache-scope.outputs.current }}
300- type=gha,scope=${{ steps.cache-scope.outputs.main }}
301- type=registry,ref=${{ env.REGISTRY_IMAGE }}:main${{ matrix.tag_suffix }}
302- cache-to : type=gha,scope=${{ steps.cache-scope.outputs.current }},mode=max
303- - name : Export digest
304- if : github.event_name != 'pull_request'
305- run : |
306- mkdir -p /tmp/digests
307- digest="${{ steps.build.outputs.digest }}"
308- touch "/tmp/digests/${digest#sha256:}"
309- - name : Upload digest
310- uses : actions/upload-artifact@v7
311- if : github.event_name != 'pull_request'
312- with :
313- name : digests-${{ matrix.variant }}${{ matrix.tag_suffix }}
314- path : /tmp/digests/*
315- if-no-files-found : error
316- retention-days : 1
317-
318- docker_build_amd64_minimal :
319- name : docker_build (linux/amd64, minimal)
320- runs-on : ubuntu-latest
321- steps :
322- - name : Checkout
323- uses : actions/checkout@v7
324- - name : Docker meta
325- id : meta
326- uses : docker/metadata-action@v6
327- with :
328- images : ${{ env.REGISTRY_IMAGE }}
329- flavor : suffix=-linux-amd64
330- labels : |
331- org.opencontainers.image.created=1970-01-01T00:00:00Z
332- - name : Set up Docker Buildx
333- uses : docker/setup-buildx-action@v4
334- - id : cache-scope
335- name : Docker cache scope
336- run : |
337- ref_scope="main"
338- if [[ "${{ github.event_name }}" == "pull_request" ]]; then
339- ref_scope="pr-${{ github.event.pull_request.number }}"
340- fi
341-
342- recipe_hash="${{ hashFiles('Dockerfile', '.cargo/**', 'Cargo.toml', 'Cargo.lock', 'build.rs', 'scripts/**', 'sqlpage/**', 'frontend/src/**', 'package.json', 'package-lock.json') }}"
343- {
344- echo "artifact=sqlpage-${ref_scope}-linux-amd64-hurl-${recipe_hash}"
345- echo "current=sqlpage-${ref_scope}-linux-amd64-${recipe_hash}"
346- echo "main=sqlpage-main-linux-amd64-${recipe_hash}"
347- } >> "$GITHUB_OUTPUT"
348- - name : Login to Docker Hub
349- if : github.event_name != 'pull_request'
350- uses : docker/login-action@v4
351- with :
352- username : ${{ env.REGISTRY_USERNAME }}
353- password : ${{ secrets.DOCKERHUB_TOKEN }}
354- - name : Build image for Hurl examples
355- uses : docker/build-push-action@v7
356- with :
357- # Use BuildKit's Git context instead of the mutable runner workspace.
358- # The dependency cache should be keyed by committed source, not by a
359- # per-job local context stream.
360- context : " {{defaultContext}}"
361- platforms : linux/amd64
362- target : minimal
363- labels : ${{ steps.meta.outputs.labels }}
364302 tags : |
365303 ${{ steps.meta.outputs.tags }}
366304 ${{ env.REGISTRY_IMAGE }}:main
@@ -369,9 +307,10 @@ jobs:
369307 type=gha,scope=${{ steps.cache-scope.outputs.artifact }}
370308 type=gha,scope=${{ steps.cache-scope.outputs.current }}
371309 type=gha,scope=${{ steps.cache-scope.outputs.main }}
372- type=registry,ref=${{ env.REGISTRY_IMAGE }}:main-linux-amd64
310+ type=registry,ref=${{ env.REGISTRY_IMAGE }}:main${{ matrix.tag_suffix }}
373311 cache-to : type=gha,scope=${{ steps.cache-scope.outputs.artifact }},mode=max
374312 - name : Upload SQLPage image
313+ if : matrix.export
375314 uses : actions/upload-artifact@v7
376315 with :
377316 name : sqlpage-linux-amd64-minimal-image
@@ -380,22 +319,22 @@ jobs:
380319 retention-days : 1
381320 - name : Build and push by digest
382321 id : build
383- if : github.event_name != 'pull_request'
322+ if : github.event_name != 'pull_request' || !matrix.export
384323 uses : docker/build-push-action@v7
385324 with :
386325 # Use BuildKit's Git context instead of the mutable runner workspace.
387326 # The dependency cache should be keyed by committed source, not by a
388327 # per-job local context stream.
389328 context : " {{defaultContext}}"
390- platforms : linux/amd64
391- target : minimal
329+ platforms : ${{ matrix.platform }}
330+ target : ${{ matrix.variant }}
392331 labels : ${{ steps.meta.outputs.labels }}
393- push : true
332+ push : ${{ github.event_name != 'pull_request' }}
394333 tags : ${{ steps.meta.outputs.tags }}
395334 cache-from : |
396335 type=gha,scope=${{ steps.cache-scope.outputs.current }}
397336 type=gha,scope=${{ steps.cache-scope.outputs.main }}
398- type=registry,ref=${{ env.REGISTRY_IMAGE }}:main-linux-amd64
337+ type=registry,ref=${{ env.REGISTRY_IMAGE }}:main${{ matrix.tag_suffix }}
399338 cache-to : type=gha,scope=${{ steps.cache-scope.outputs.current }},mode=max
400339 - name : Export digest
401340 if : github.event_name != 'pull_request'
@@ -407,11 +346,10 @@ jobs:
407346 uses : actions/upload-artifact@v7
408347 if : github.event_name != 'pull_request'
409348 with :
410- name : digests-minimal-linux-amd64
349+ name : digests-${{ matrix.variant }}${{ matrix.tag_suffix }}
411350 path : /tmp/digests/*
412351 if-no-files-found : error
413352 retention-days : 1
414-
415353 hurl_examples :
416354 runs-on : ubuntu-latest
417355 outputs :
@@ -456,7 +394,6 @@ jobs:
456394 runs-on : ubuntu-latest
457395 timeout-minutes : 15
458396 needs :
459- - docker_build_amd64_minimal
460397 - hurl_examples
461398 strategy :
462399 fail-fast : false
@@ -497,7 +434,6 @@ jobs:
497434 runs-on : ubuntu-latest
498435 if : github.event_name != 'pull_request'
499436 needs :
500- - docker_build_amd64_minimal
501437 - docker_build
502438 strategy :
503439 matrix :
0 commit comments