@@ -419,6 +419,108 @@ jobs:
419
419
if-no-files-found : error
420
420
retention-days : 1
421
421
422
+ build-slim-image :
423
+ runs-on : ${{ matrix.runner }}
424
+ permissions :
425
+ contents : read
426
+ packages : write
427
+ strategy :
428
+ fail-fast : false
429
+ matrix :
430
+ include :
431
+ - platform : linux/amd64
432
+ runner : ubuntu-latest
433
+ - platform : linux/arm64
434
+ runner : ubuntu-24.04-arm
435
+
436
+ steps :
437
+ # GitHub Packages requires the entire repository name to be in lowercase
438
+ # although the repository owner has a lowercase username, this prevents some people from running actions after forking
439
+ - name : Set repository and image name to lowercase
440
+ run : |
441
+ echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
442
+ echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
443
+ env :
444
+ IMAGE_NAME : ' ${{ github.repository }}'
445
+
446
+ - name : Prepare
447
+ run : |
448
+ platform=${{ matrix.platform }}
449
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
450
+
451
+ - name : Checkout repository
452
+ uses : actions/checkout@v4
453
+
454
+ - name : Set up QEMU
455
+ uses : docker/setup-qemu-action@v3
456
+
457
+ - name : Set up Docker Buildx
458
+ uses : docker/setup-buildx-action@v3
459
+
460
+ - name : Log in to the Container registry
461
+ uses : docker/login-action@v3
462
+ with :
463
+ registry : ${{ env.REGISTRY }}
464
+ username : ${{ github.actor }}
465
+ password : ${{ secrets.GITHUB_TOKEN }}
466
+
467
+ - name : Extract metadata for Docker images (slim tag)
468
+ id : meta
469
+ uses : docker/metadata-action@v5
470
+ with :
471
+ images : ${{ env.FULL_IMAGE_NAME }}
472
+ tags : |
473
+ type=ref,event=branch
474
+ type=ref,event=tag
475
+ type=sha,prefix=git-
476
+ type=semver,pattern={{version}}
477
+ type=semver,pattern={{major}}.{{minor}}
478
+ type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=slim
479
+ flavor : |
480
+ latest=${{ github.ref == 'refs/heads/main' }}
481
+ suffix=-slim,onlatest=true
482
+
483
+ - name : Extract metadata for Docker cache
484
+ id : cache-meta
485
+ uses : docker/metadata-action@v5
486
+ with :
487
+ images : ${{ env.FULL_IMAGE_NAME }}
488
+ tags : |
489
+ type=ref,event=branch
490
+ ${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
491
+ flavor : |
492
+ prefix=cache-slim-${{ matrix.platform }}-
493
+ latest=false
494
+
495
+ - name : Build Docker image (slim)
496
+ uses : docker/build-push-action@v5
497
+ id : build
498
+ with :
499
+ context : .
500
+ push : true
501
+ platforms : ${{ matrix.platform }}
502
+ labels : ${{ steps.meta.outputs.labels }}
503
+ outputs : type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
504
+ cache-from : type=registry,ref=${{ steps.cache-meta.outputs.tags }}
505
+ cache-to : type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
506
+ build-args : |
507
+ BUILD_HASH=${{ github.sha }}
508
+ USE_SLIM=true
509
+
510
+ - name : Export digest
511
+ run : |
512
+ mkdir -p /tmp/digests
513
+ digest="${{ steps.build.outputs.digest }}"
514
+ touch "/tmp/digests/${digest#sha256:}"
515
+
516
+ - name : Upload digest
517
+ uses : actions/upload-artifact@v4
518
+ with :
519
+ name : digests-slim-${{ env.PLATFORM_PAIR }}
520
+ path : /tmp/digests/*
521
+ if-no-files-found : error
522
+ retention-days : 1
523
+
422
524
merge-main-images :
423
525
runs-on : ubuntu-latest
424
526
needs : [build-main-image]
@@ -640,3 +742,59 @@ jobs:
640
742
- name : Inspect image
641
743
run : |
642
744
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
745
+
746
+ merge-slim-images :
747
+ runs-on : ubuntu-latest
748
+ needs : [build-slim-image]
749
+ steps :
750
+ # GitHub Packages requires the entire repository name to be in lowercase
751
+ # although the repository owner has a lowercase username, this prevents some people from running actions after forking
752
+ - name : Set repository and image name to lowercase
753
+ run : |
754
+ echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
755
+ echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
756
+ env :
757
+ IMAGE_NAME : ' ${{ github.repository }}'
758
+
759
+ - name : Download digests
760
+ uses : actions/download-artifact@v4
761
+ with :
762
+ pattern : digests-slim-*
763
+ path : /tmp/digests
764
+ merge-multiple : true
765
+
766
+ - name : Set up Docker Buildx
767
+ uses : docker/setup-buildx-action@v3
768
+
769
+ - name : Log in to the Container registry
770
+ uses : docker/login-action@v3
771
+ with :
772
+ registry : ${{ env.REGISTRY }}
773
+ username : ${{ github.actor }}
774
+ password : ${{ secrets.GITHUB_TOKEN }}
775
+
776
+ - name : Extract metadata for Docker images (default slim tag)
777
+ id : meta
778
+ uses : docker/metadata-action@v5
779
+ with :
780
+ images : ${{ env.FULL_IMAGE_NAME }}
781
+ tags : |
782
+ type=ref,event=branch
783
+ type=ref,event=tag
784
+ type=sha,prefix=git-
785
+ type=semver,pattern={{version}}
786
+ type=semver,pattern={{major}}.{{minor}}
787
+ type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=slim
788
+ flavor : |
789
+ latest=${{ github.ref == 'refs/heads/main' }}
790
+ suffix=-slim,onlatest=true
791
+
792
+ - name : Create manifest list and push
793
+ working-directory : /tmp/digests
794
+ run : |
795
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
796
+ $(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
797
+
798
+ - name : Inspect image
799
+ run : |
800
+ docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
0 commit comments