Skip to content

Commit baf21cf

Browse files
committed
feat: fixes for beta support
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent 6c20c6f commit baf21cf

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ ARG BASE=debian:12.10-slim
22
FROM $BASE AS minimal
33

44
ARG PG_VERSION
5-
ARG PG_MAJOR=${PG_VERSION%%.*}
5+
ARG PG_MAJOR
66

77
ENV PATH=$PATH:/usr/lib/postgresql/$PG_MAJOR/bin
88

99
RUN apt-get update && \
1010
apt-get install -y --no-install-recommends postgresql-common ca-certificates gnupg && \
11-
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && \
11+
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y -c "${PG_MAJOR}" && \
1212
apt-get install -y --no-install-recommends -o Dpkg::::="--force-confdef" -o Dpkg::::="--force-confold" postgresql-common && \
1313
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf && \
1414
apt-get install -y --no-install-recommends \
@@ -21,13 +21,10 @@ USER 26
2121

2222

2323
FROM minimal AS standard
24-
24+
ARG EXTENSIONS
2525
USER root
2626
RUN apt-get update && \
27-
apt-get install -y --no-install-recommends locales-all \
28-
"postgresql-${PG_MAJOR}-pgaudit" \
29-
"postgresql-${PG_MAJOR}-pgvector" \
30-
"postgresql-${PG_MAJOR}-pg-failover-slots" && \
27+
apt-get install -y --no-install-recommends locales-all "${EXTENSIONS}" && \
3128
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
3229
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
3330

docker-bake.hcl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ now = timestamp()
2020
authors = "The CloudNativePG Contributors"
2121
url = "https://github.com/cloudnative-pg/postgres-containers"
2222

23+
extensions = [
24+
"pgaudit",
25+
"pgvector",
26+
"pg-failover-slots"
27+
]
28+
2329
target "default" {
2430
matrix = {
2531
tgt = [
@@ -56,7 +62,9 @@ target "default" {
5662
target = "${tgt}"
5763
args = {
5864
PG_VERSION = "${pgVersion}"
65+
PG_MAJOR = "${getMajor(pgVersion)}"
5966
BASE = "${base}"
67+
EXTENSIONS = "${getExtensionsString(pgVersion, extensions)}"
6068
}
6169
attest = [
6270
"type=provenance,mode=max",
@@ -113,3 +121,18 @@ function cleanVersion {
113121
params = [ version ]
114122
result = replace(version, "~", "")
115123
}
124+
125+
function isBeta {
126+
params = [ version ]
127+
result = (length(regexall("[0-9]+~beta.*", version)) > 0) ? true : false
128+
}
129+
130+
function getMajor {
131+
params = [ version ]
132+
result = (isBeta(version) == true) ? index(split("~", version),0) : index(split(".", version),0)
133+
}
134+
135+
function getExtensionsString {
136+
params = [ version, extensions ]
137+
result = (isBeta(version) == true) ? "" : join(" ", formatlist("postgresql-%s-%s", getMajor(version), extensions))
138+
}

0 commit comments

Comments
 (0)