chore: add support for PostgreSQL beta versions (#191)

Now bake supports beta versions for the list and the building of the images

Closes #190

Signed-off-by: Jonathan Gonzalez V <jonathan.gonzalez@enterprisedb.com>
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
Co-authored-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
This commit is contained in:
Jonathan Gonzalez V.
2025-05-23 15:14:49 +02:00
committed by GitHub
parent b1421da867
commit 23e1fa6181
2 changed files with 38 additions and 12 deletions

View File

@@ -2,13 +2,13 @@ ARG BASE=debian:12.11-slim
FROM $BASE AS minimal
ARG PG_VERSION
ARG PG_MAJOR=${PG_VERSION%%.*}
ARG PG_MAJOR
ENV PATH=$PATH:/usr/lib/postgresql/$PG_MAJOR/bin
RUN apt-get update && \
apt-get install -y --no-install-recommends postgresql-common ca-certificates gnupg && \
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && \
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y -c "${PG_MAJOR}" && \
apt-get install -y --no-install-recommends -o Dpkg::::="--force-confdef" -o Dpkg::::="--force-confold" postgresql-common && \
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf && \
apt-get install -y --no-install-recommends \
@@ -21,13 +21,10 @@ USER 26
FROM minimal AS standard
ARG EXTENSIONS
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends locales-all \
"postgresql-${PG_MAJOR}-pgaudit" \
"postgresql-${PG_MAJOR}-pgvector" \
"postgresql-${PG_MAJOR}-pg-failover-slots" && \
apt-get install -y --no-install-recommends locales-all ${EXTENSIONS} && \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*

View File

@@ -20,6 +20,12 @@ now = timestamp()
authors = "The CloudNativePG Contributors"
url = "https://github.com/cloudnative-pg/postgres-containers"
extensions = [
"pgaudit",
"pgvector",
"pg-failover-slots"
]
target "default" {
matrix = {
tgt = [
@@ -31,7 +37,8 @@ target "default" {
"14.18",
"15.13",
"16.9",
"17.5"
"17.5",
"18~beta1"
]
base = [
// renovate: datasource=docker versioning=loose
@@ -45,17 +52,19 @@ target "default" {
"linux/arm64"
]
dockerfile = "Dockerfile"
name = "postgresql-${index(split(".",pgVersion),0)}-${tgt}-${distroVersion(base)}"
name = "postgresql-${index(split(".",cleanVersion(pgVersion)),0)}-${tgt}-${distroVersion(base)}"
tags = [
"${fullname}:${index(split(".",pgVersion),0)}-${tgt}-${distroVersion(base)}",
"${fullname}:${pgVersion}-${tgt}-${distroVersion(base)}",
"${fullname}:${pgVersion}-${formatdate("YYYYMMDDhhmm", now)}-${tgt}-${distroVersion(base)}"
"${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)}"
}
attest = [
"type=provenance,mode=max",
@@ -107,3 +116,23 @@ function digest {
params = [ imageNameWithSha ]
result = index(split("@", imageNameWithSha), 1)
}
function cleanVersion {
params = [ version ]
result = replace(version, "~", "")
}
function isBeta {
params = [ version ]
result = length(regexall("[0-9]+~beta.*", version)) > 0
}
function getMajor {
params = [ version ]
result = (isBeta(version) == true) ? index(split("~", version),0) : index(split(".", version),0)
}
function getExtensionsString {
params = [ version, extensions ]
result = (isBeta(version) == true) ? "" : join(" ", formatlist("postgresql-%s-%s", getMajor(version), extensions))
}