forked from repo-mirrors/cnpg-postgres-containers
Closes #294 Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Co-authored-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>
173 lines
5.7 KiB
HCL
173 lines
5.7 KiB
HCL
variable "environment" {
|
|
default = "testing"
|
|
validation {
|
|
condition = contains(["testing", "production"], environment)
|
|
error_message = "environment must be either testing or production"
|
|
}
|
|
}
|
|
|
|
variable "registry" {
|
|
default = "localhost:5000"
|
|
}
|
|
|
|
// Use the revision variable to identify the commit that generated the image
|
|
variable "revision" {
|
|
default = ""
|
|
}
|
|
|
|
fullname = ( environment == "testing") ? "${registry}/postgresql-testing" : "${registry}/postgresql"
|
|
now = timestamp()
|
|
authors = "The CloudNativePG Contributors"
|
|
url = "https://github.com/cloudnative-pg/postgres-containers"
|
|
|
|
// PostgreSQL versions to build
|
|
postgreSQLVersions = [
|
|
"13.22",
|
|
"14.19",
|
|
"15.14",
|
|
"16.10",
|
|
"17.6"
|
|
]
|
|
|
|
// PostgreSQL preview versions to build, such as "18~beta1" or "18~rc1"
|
|
// Preview versions are automatically filtered out if present in the stable list
|
|
// MANUALLY EDIT THE CONTENT - AND UPDATE THE README.md FILE TOO
|
|
postgreSQLPreviewVersions = [
|
|
"18~rc1",
|
|
]
|
|
|
|
// Barman version to build
|
|
# renovate: datasource=github-releases depName=EnterpriseDB/barman versioning=loose
|
|
barmanVersion = "3.14.0"
|
|
|
|
extensions = [
|
|
"pgaudit",
|
|
"pgvector",
|
|
"pg-failover-slots"
|
|
]
|
|
|
|
target "default" {
|
|
matrix = {
|
|
tgt = [
|
|
"minimal",
|
|
"standard",
|
|
"system"
|
|
]
|
|
// Get the list of PostgreSQL versions, filtering preview versions if already stable
|
|
pgVersion = getPgVersions(postgreSQLVersions, postgreSQLPreviewVersions)
|
|
base = [
|
|
// renovate: datasource=docker versioning=loose
|
|
"debian:trixie-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb",
|
|
// renovate: datasource=docker versioning=loose
|
|
"debian:bookworm-slim@sha256:b1a741487078b369e78119849663d7f1a5341ef2768798f7b7406c4240f86aef",
|
|
// renovate: datasource=docker versioning=loose
|
|
"debian:bullseye-slim@sha256:849d9d34d5fe0bf88b5fb3d09eb9684909ac4210488b52f4f7bbe683eedcb851"
|
|
]
|
|
}
|
|
platforms = [
|
|
"linux/amd64",
|
|
"linux/arm64"
|
|
]
|
|
dockerfile = "Dockerfile"
|
|
name = "postgresql-${index(split(".",cleanVersion(pgVersion)),0)}-${tgt}-${distroVersion(base)}"
|
|
tags = [
|
|
"${fullname}:${index(split(".",cleanVersion(pgVersion)),0)}-${tgt}-${distroVersion(base)}",
|
|
"${fullname}:${cleanVersion(pgVersion)}-${tgt}-${distroVersion(base)}",
|
|
"${fullname}:${cleanVersion(pgVersion)}-${formatdate("YYYYMMDDhhmm", now)}-${tgt}-${distroVersion(base)}"
|
|
]
|
|
context = "."
|
|
target = "${tgt}"
|
|
args = {
|
|
PG_VERSION = "${pgVersion}"
|
|
PG_MAJOR = "${getMajor(pgVersion)}"
|
|
BASE = "${base}"
|
|
EXTENSIONS = "${getExtensionsString(pgVersion, extensions)}"
|
|
BARMAN_VERSION = "${barmanVersion}"
|
|
}
|
|
attest = [
|
|
"type=provenance,mode=max",
|
|
"type=sbom"
|
|
]
|
|
annotations = [
|
|
"index,manifest:org.opencontainers.image.created=${now}",
|
|
"index,manifest:org.opencontainers.image.url=${url}",
|
|
"index,manifest:org.opencontainers.image.source=${url}",
|
|
"index,manifest:org.opencontainers.image.version=${pgVersion}",
|
|
"index,manifest:org.opencontainers.image.revision=${revision}",
|
|
"index,manifest:org.opencontainers.image.vendor=${authors}",
|
|
"index,manifest:org.opencontainers.image.title=CloudNativePG PostgreSQL ${pgVersion} ${tgt}",
|
|
"index,manifest:org.opencontainers.image.description=A ${tgt} PostgreSQL ${pgVersion} container image",
|
|
"index,manifest:org.opencontainers.image.documentation=https://github.com/cloudnative-pg/postgres-containers",
|
|
"index,manifest:org.opencontainers.image.authors=${authors}",
|
|
"index,manifest:org.opencontainers.image.licenses=Apache-2.0",
|
|
"index,manifest:org.opencontainers.image.base.name=docker.io/library/${tag(base)}",
|
|
"index,manifest:org.opencontainers.image.base.digest=${digest(base)}"
|
|
]
|
|
labels = {
|
|
"org.opencontainers.image.created" = "${now}",
|
|
"org.opencontainers.image.url" = "${url}",
|
|
"org.opencontainers.image.source" = "${url}",
|
|
"org.opencontainers.image.version" = "${pgVersion}",
|
|
"org.opencontainers.image.revision" = "${revision}",
|
|
"org.opencontainers.image.vendor" = "${authors}",
|
|
"org.opencontainers.image.title" = "CloudNativePG PostgreSQL ${pgVersion} ${tgt}",
|
|
"org.opencontainers.image.description" = "A ${tgt} PostgreSQL ${pgVersion} container image",
|
|
"org.opencontainers.image.documentation" = "${url}",
|
|
"org.opencontainers.image.authors" = "${authors}",
|
|
"org.opencontainers.image.licenses" = "Apache-2.0"
|
|
"org.opencontainers.image.base.name" = "docker.io/library/debian:${tag(base)}"
|
|
"org.opencontainers.image.base.digest" = "${digest(base)}"
|
|
}
|
|
}
|
|
|
|
function tag {
|
|
params = [ imageNameWithSha ]
|
|
result = index(split("@", index(split(":", imageNameWithSha), 1)), 0)
|
|
}
|
|
|
|
function distroVersion {
|
|
params = [ imageNameWithSha ]
|
|
result = index(split("-", tag(imageNameWithSha)), 0)
|
|
}
|
|
|
|
function digest {
|
|
params = [ imageNameWithSha ]
|
|
result = index(split("@", imageNameWithSha), 1)
|
|
}
|
|
|
|
function cleanVersion {
|
|
params = [ version ]
|
|
result = replace(version, "~", "")
|
|
}
|
|
|
|
function isPreview {
|
|
params = [ version ]
|
|
result = length(regexall("[0-9]+~(alpha|beta|rc).*", version)) > 0
|
|
}
|
|
|
|
function getMajor {
|
|
params = [ version ]
|
|
result = (isPreview(version) == true) ? index(split("~", version),0) : index(split(".", version),0)
|
|
}
|
|
|
|
function getExtensionsString {
|
|
params = [ version, extensions ]
|
|
result = (isPreview(version) == true) ? "" : join(" ", formatlist("postgresql-%s-%s", getMajor(version), extensions))
|
|
}
|
|
|
|
function isMajorPresent {
|
|
params = [major, pgVersions]
|
|
result = contains([for v in pgVersions : getMajor(v)], major)
|
|
}
|
|
|
|
function getPgVersions {
|
|
params = [stableVersions, previewVersions]
|
|
// Remove any preview version if already present as stable
|
|
result = concat(stableVersions,
|
|
[
|
|
for v in previewVersions : v
|
|
if !isMajorPresent(getMajor(v), stableVersions)
|
|
]
|
|
)
|
|
}
|