Skip to content

chore: add support for PostgreSQL beta versions #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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/*

Expand Down
39 changes: 34 additions & 5 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -31,7 +37,8 @@ target "default" {
"14.18",
"15.13",
"16.9",
"17.5"
"17.5",
"18~beta1"
]
base = [
// renovate: datasource=docker versioning=loose
Expand All @@ -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",
Expand Down Expand Up @@ -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))
}