|
| 1 | +variable "environment" { |
| 2 | + default = "testing" |
| 3 | + validation { |
| 4 | + condition = contains(["testing", "production"], environment) |
| 5 | + error_message = "environment must be either testing or production" |
| 6 | + } |
| 7 | +} |
| 8 | + |
| 9 | +variable "registry" { |
| 10 | + default = "localhost:5000" |
| 11 | +} |
| 12 | + |
| 13 | +// Use the revision variable to identify the commit that generated the image |
| 14 | +variable "revision" { |
| 15 | + default = "" |
| 16 | +} |
| 17 | + |
| 18 | +fullname = ( environment == "testing") ? "${registry}/postgresql-testing" : "{registry}/postgresql" |
| 19 | +now = timestamp() |
| 20 | + |
| 21 | +target "default" { |
| 22 | + matrix = { |
| 23 | + tgt = [ |
| 24 | + "minimal", |
| 25 | + // "standard" |
| 26 | + ] |
| 27 | + pgVersion = [ |
| 28 | + // "13.18", |
| 29 | + // "14.15", |
| 30 | + // "15.10", |
| 31 | + "16.6", |
| 32 | + "17.2" |
| 33 | + ] |
| 34 | + base = [ |
| 35 | + // renovate: datasource=docker versioning=loose |
| 36 | + // "debian:bookworm-slim@sha256:d365f4920711a9074c4bcd178e8f457ee59250426441ab2a5f8106ed8fe948eb", |
| 37 | + // renovate: datasource=docker versioning=loose |
| 38 | + "debian:bullseye-slim@sha256:b0c91cc181796d34c53f7ea106fbcddaf87f3e601cc371af6a24a019a489c980" |
| 39 | + ] |
| 40 | + } |
| 41 | + dockerfile = "Dockerfile" |
| 42 | + name = "postgresql-${index(split(".",pgVersion),0)}-${distroVersion(base)}-${tgt}" |
| 43 | + tags = [ |
| 44 | + "${fullname}:${index(split(".",pgVersion),0)}-${distroVersion(base)}-${tgt}", |
| 45 | + "${fullname}:${pgVersion}-${distroVersion(base)}-${tgt}", |
| 46 | + "${fullname}:${pgVersion}-${formatdate("YYYYMMDDhhmm", now)}-${distroVersion(base)}-${tgt}" |
| 47 | + ] |
| 48 | + context = "." |
| 49 | + target = "${tgt}" |
| 50 | + args = { |
| 51 | + PG_VERSION = "${pgVersion}" |
| 52 | + BASE = "${base}" |
| 53 | + } |
| 54 | + attest = [ |
| 55 | + "type=provenance,mode=max", |
| 56 | + "type=sbom" |
| 57 | + ] |
| 58 | + annotations = [ |
| 59 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.created=${now}", |
| 60 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.url=https://github.com/cloudnative-pg/postgres-containers", |
| 61 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.source=https://github.com/cloudnative-pg/postgres-containers", |
| 62 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.version=${pgVersion}", |
| 63 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.revision=${revision}", |
| 64 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.vendor=The CloudNativePG Contributors", |
| 65 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.title=CloudNativePG PostgreSQL ${pgVersion} ${tgt}", |
| 66 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.description=A ${tgt} PostgreSQL ${pgVersion} container image", |
| 67 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.documentation=https://github.com/cloudnative-pg/postgres-containers", |
| 68 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.authors=The CloudNativePG Contributors", |
| 69 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.licenses=Apache-2.0", |
| 70 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.base.name=docker.io/library/${tag(base)}", |
| 71 | + "index,manifest,manifest-descriptor,index-descriptor:org.opencontainers.image.base.digest=${digest(base)}" |
| 72 | + ] |
| 73 | + labels = { |
| 74 | + "org.opencontainers.image.created" = "${now}", |
| 75 | + "org.opencontainers.image.url" = "https://github.com/cloudnative-pg/postgres-containers", |
| 76 | + "org.opencontainers.image.source" = "https://github.com/cloudnative-pg/postgres-containers", |
| 77 | + "org.opencontainers.image.version" = "${pgVersion}", |
| 78 | + "org.opencontainers.image.revision" = "${revision}", |
| 79 | + "org.opencontainers.image.vendor" = "The CloudNativePG Contributors", |
| 80 | + "org.opencontainers.image.title" = "CloudNativePG PostgreSQL ${pgVersion} ${tgt}", |
| 81 | + "org.opencontainers.image.description" = "A ${tgt} PostgreSQL ${pgVersion} container image", |
| 82 | + "org.opencontainers.image.documentation" = "https://github.com/cloudnative-pg/postgres-containers", |
| 83 | + "org.opencontainers.image.authors" = "The CloudNativePG Contributors", |
| 84 | + "org.opencontainers.image.licenses" = "Apache-2.0" |
| 85 | + "org.opencontainers.image.base.name" = "docker.io/library/debian:${tag(base)}" |
| 86 | + "org.opencontainers.image.base.digest" = "${digest(base)}" |
| 87 | + } |
| 88 | + //platforms = ["linux/amd64", "linux/arm64"] |
| 89 | +} |
| 90 | + |
| 91 | +function tag { |
| 92 | + params = [ imageNameWithSha ] |
| 93 | + result = index(split("@", index(split(":", imageNameWithSha), 1)), 0) |
| 94 | +} |
| 95 | + |
| 96 | +function distroVersion { |
| 97 | + params = [ imageNameWithSha ] |
| 98 | + result = index(split("-", tag(imageNameWithSha)), 0) |
| 99 | +} |
| 100 | + |
| 101 | +function digest { |
| 102 | + params = [ imageNameWithSha ] |
| 103 | + result = index(split("@", imageNameWithSha), 1) |
| 104 | +} |
0 commit comments