Skip to content

Commit

Permalink
feat: support docker/metadata-action for tags on GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed Jul 12, 2024
1 parent bde3e89 commit 96f109a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
18 changes: 12 additions & 6 deletions containers/debian/base.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ variable "BUILD_IMAGE" { default = "debian_base" }
# Variables whose defaults can be overridden on build
variable "BASE_IMAGE" { default = null }

# docker/metadata-action overrides the following target with tags
# but we implement it for use outside docker/metadata-action
target "docker-metadata-action" {
tags = compact(flatten([
join("/", compact([ CI_REGISTRY, CI_PROJECT_PATH, "${BUILD_IMAGE}:${INTERNAL_TAG}"]) ),
EXPORT_TAG != null && EXPORT_TAG != "" ? [
for registry in registries: "${registry}/${BUILD_IMAGE}:${EXPORT_TAG}"
] : [ null ]
]))
}

target "default" {
inherits = ["docker-metadata-action"]
attest = [
"type=provenance,disabled=true"
]
Expand All @@ -15,10 +27,4 @@ target "default" {
BASE_IMAGE = BASE_IMAGE
BUILD_IMAGE = BUILD_IMAGE
}
tags = compact(flatten([
join("/", compact([ CI_REGISTRY, CI_PROJECT_PATH, "${BUILD_IMAGE}:${INTERNAL_TAG}"]) ),
EXPORT_TAG != null && EXPORT_TAG != "" ? [
for registry in registries: "${registry}/${BUILD_IMAGE}:${EXPORT_TAG}"
] : [ null ]
]))
}
26 changes: 16 additions & 10 deletions containers/jug/dev.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,23 @@ image_names = [
replace(image_name,"eic","jug")
]

# docker/metadata-action overrides the following target with tags
# but we implement it for use outside docker/metadata-action
target "docker-metadata-action" {
tags = compact(flatten([
[
for image_name in image_names:
join("/", compact([ CI_REGISTRY, CI_PROJECT_PATH, "${image_name}:${INTERNAL_TAG}"]) )
],
EXPORT_TAG != null && EXPORT_TAG != "" ? [
for registry_image_name in setproduct(registries, image_names):
format("%s:%s", join("/", registry_image_name), EXPORT_TAG )
] : [ null ]
]))
}

target "default" {
inherits = ["docker-metadata-action"]
attest = [
"type=provenance,disabled=true"
]
Expand Down Expand Up @@ -63,14 +79,4 @@ target "default" {
EPIC_VERSION = BUILD_TYPE == "default" ? EPIC_VERSION : "main"
JUGGLER_VERSION = BUILD_TYPE == "default" ? JUGGLER_VERSION : "main"
}
tags = compact(flatten([
[
for image_name in image_names:
join("/", compact([ CI_REGISTRY, CI_PROJECT_PATH, "${image_name}:${INTERNAL_TAG}"]) )
],
EXPORT_TAG != null && EXPORT_TAG != "" ? [
for registry_image_name in setproduct(registries, image_names):
format("%s:%s", join("/", registry_image_name), EXPORT_TAG )
] : [ null ]
]))
}

0 comments on commit 96f109a

Please sign in to comment.