diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 4438a2e41..5a9d6b2b5 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -27,7 +27,7 @@ on: # - cron: '0 0 * * 0' env: - REGISTRY_IMAGE: ghcr.io/finnhering/julea-prebuilt + REGISTRY_IMAGE: ghcr.io/finnhering/julea jobs: @@ -69,8 +69,25 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + REGISTRY_IMAGE + tags: | + type=sha + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - name: Build and Push uses: docker/bake-action@v5 + env: + COMMIT_SHA: ${{ github.sha }} + BASE_TAG: ${{ env.BASE_TAG}} with: + targets: ${{ matrix.target }} push: true + files: | + ./docker-bake.hcl + ${{ steps.meta.outputs.bake-file }} diff --git a/docker-bake.hcl b/docker-bake.hcl index 6b572fdbd..0ae0d98b3 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -6,6 +6,10 @@ variable "BASE_TAG" { default = "ghcr.io/finnhering/julea" } +variable "COMMIT_SHA" { + default = "UNKNOWN" +} + group "ubuntu" { targets = ["ubuntu-spack", "ubuntu-system", "ubuntu-latest", "ubuntu-dev-container"] } @@ -25,7 +29,7 @@ target "ubuntu-spack" { } # Add -dependencies to the tag if the target is julea_dependencies - tags = ["${BASE_TAG}-spack:ubuntu-${versions}-04-${compilers}"] + tags = ["${BASE_TAG}-spack:ubuntu-${versions}-04-${compilers}", "${BASE_TAG}-spack:ubuntu-${versions}-04-${compilers}-${COMMIT_SHA}"] target = "julea" dockerfile = "Dockerfile.spack" cache-from = [ @@ -48,7 +52,7 @@ target "ubuntu-system" { UBUNTU_VERSION = "${versions}.04" CC = compilers } - tags = ["${BASE_TAG}-system:ubuntu-${versions}-04-${compilers}"] + tags = ["${BASE_TAG}-system:ubuntu-${versions}-04-${compilers}", "${BASE_TAG}-system:ubuntu-${versions}-04-${compilers}-${COMMIT_SHA}"] target = "julea" dockerfile = "Dockerfile.system" @@ -69,7 +73,7 @@ target "ubuntu-latest" { UBUNTU_VERSION = "24.04" CC = "gcc" } - tags = ["${BASE_TAG}:latest"] + tags = ["${BASE_TAG}:latest", "{BASE_TAG}:latest-${COMMIT_SHA}"] target = "julea" dockerfile = "Dockerfile.system" @@ -89,10 +93,10 @@ target "ubuntu-dev-container" { UBUNTU_VERSION = "24.04" CC = "gcc" } - tags = ["${BASE_TAG}-dev-container:latest"] + tags = ["${BASE_TAG}-dev-container:latest", "${BASE_TAG}-dev-container:latest-${COMMIT_SHA}"] target = "julea_dependencies" dockerfile = "Dockerfile.spack" - + cache-from = [ "type=gha,scope=julea-ubuntu-24-04-spack-gcc" ]