Skip to content

Commit

Permalink
chore: pass base_tag and commit_hash variables to bakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnHering committed Oct 24, 2024
1 parent bd0b531 commit 2fef9c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
# - cron: '0 0 * * 0'

env:
REGISTRY_IMAGE: ghcr.io/finnhering/julea-prebuilt
REGISTRY_IMAGE: ghcr.io/finnhering/julea

jobs:

Expand Down Expand Up @@ -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 }}
14 changes: 9 additions & 5 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
Expand All @@ -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 = [
Expand All @@ -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"

Expand All @@ -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"

Expand All @@ -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"
]
Expand Down

0 comments on commit 2fef9c0

Please sign in to comment.