Skip to content

Commit 03826f4

Browse files
committed
wip
1 parent 4149cb0 commit 03826f4

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
ARG DISTRO=debian:bookworm-slim
2+
FROM $DISTRO AS minimal
3+
4+
ARG PG_VERSION
5+
ARG PG_MAJOR=${PG_VERSION%%.*}
6+
ARG BUILDTIME
7+
ARG REVISION
8+
9+
LABEL org.opencontainers.image.created="$BUILDTIME"
10+
LABEL org.opencontainers.image.url="https://github.com/cloudnative-pg/postgres-containers"
11+
LABEL org.opencontainers.image.source="https://github.com/cloudnative-pg/postgres-containers"
12+
LABEL org.opencontainers.image.version="$PG_VERSION"
13+
LABEL org.opencontainers.image.revision="$REVISION"
14+
LABEL org.opencontainers.image.vendor="The CloudNativePG Contributors"
15+
LABEL org.opencontainers.image.title="CloudNativePG PostgreSQL $PG_VERSION minimal"
16+
LABEL org.opencontainers.image.description="A minimal PostgreSQL $PG_VERSION container image"
17+
LABEL org.opencontainers.image.documentation="https://github.com/cloudnative-pg/postgres-containers"
18+
LABEL org.opencontainers.image.authors="The CloudNativePG Contributors"
19+
LABEL org.opencontainers.image.licenses="Apache-2.0"
20+
21+
ENV PATH=$PATH:/usr/lib/postgresql/$PG_MAJOR/bin
22+
23+
RUN apt-get update && \
24+
apt-get install -y --no-install-recommends postgresql-common ca-certificates gnupg && \
25+
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && \
26+
apt-get install --no-install-recommends -o Dpkg::::="--force-confdef" -o Dpkg::::="--force-confold" postgresql-common -y && \
27+
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf && \
28+
apt-get install --no-install-recommends \
29+
-o Dpkg::::="--force-confdef" -o Dpkg::::="--force-confold" "postgresql-${PG_MAJOR}=${PG_VERSION}*" -y && \
30+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
31+
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
32+
33+
34+
RUN usermod -u 26 postgres
35+
USER 26
36+
37+
FROM minimal AS standard
38+
39+
LABEL org.opencontainers.image.title="CloudNativePG PostgreSQL $PG_VERSION standard"
40+
LABEL org.opencontainers.image.description="A standard PostgreSQL $PG_VERSION container image, with a few extensions and all the locales"
41+
42+
USER root
43+
RUN apt-get update && \
44+
apt-get install -y --no-install-recommends locales-all \
45+
"postgresql-${PG_MAJOR}-pgaudit" \
46+
"postgresql-${PG_MAJOR}-pgvector" \
47+
"postgresql-${PG_MAJOR}-pg-failover-slots" && \
48+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
49+
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
50+
51+
USER 26

bake.hcl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
fullname = ( environment == "testing") ? "${registry}/postgresql-testing" : "{registry}/postgresql"
14+
now = timestamp()
15+
16+
target "postgresql" {
17+
matrix = {
18+
tgt = ["minimal", "standard"]
19+
pgVersion = [
20+
// "13.18",
21+
// "14.15",
22+
// "15.10",
23+
"16.6",
24+
"17.2"
25+
]
26+
distroVersion = [
27+
// "bookworm-20241223-slim",
28+
"bullseye-20241223-slim"
29+
]
30+
}
31+
dockerfile = "Dockerfile"
32+
name = "postgresql-${index(split(".",pgVersion),0)}-${index(split("-",distroVersion),0)}-${tgt}"
33+
tags = [
34+
"${fullname}:${index(split(".",pgVersion),0)}-${index(split("-",distroVersion),0)}-${tgt}",
35+
"${fullname}:${pgVersion}-${index(split("-",distroVersion),0)}-${tgt}",
36+
"${fullname}:${pgVersion}-${formatdate("YYYYMMDDhhmm", now)}-${index(split("-",distroVersion),0)}-${tgt}"
37+
]
38+
context = "."
39+
target = "${tgt}"
40+
args = {
41+
PG_VERSION = "${pgVersion}"
42+
DISTRO = "debian:${distroVersion}"
43+
BUILDTIME = "${now}"
44+
REVISION = "${formatdate("YYYYMMDDhhmm", now)}"
45+
}
46+
attest = [
47+
"type=provenance,mode=max",
48+
"type=sbom"
49+
]
50+
annotations = [
51+
"index,manifest:org.opencontainers.image.created=${now}",
52+
"index,manifest:org.opencontainers.image.url=https://github.com/cloudnative-pg/postgres-containers",
53+
"index,manifest:org.opencontainers.image.source=https://github.com/cloudnative-pg/postgres-containers",
54+
"index,manifest:org.opencontainers.image.version=${pgVersion}",
55+
"index,manifest:org.opencontainers.image.revision=${formatdate("YYYYMMDDhhmm", now)}",
56+
"index,manifest:org.opencontainers.image.vendor=The CloudNativePG Contributors",
57+
"index,manifest:org.opencontainers.image.title=CloudNativePG PostgreSQL ${pgVersion} minimal",
58+
"index,manifest:org.opencontainers.image.description=A minimal PostgreSQL ${pgVersion} container image",
59+
"index,manifest:org.opencontainers.image.documentation=https://github.com/cloudnative-pg/postgres-containers",
60+
"index,manifest:org.opencontainers.image.authors=The CloudNativePG Contributors",
61+
"index,manifest:org.opencontainers.image.licenses=Apache-2.0"
62+
]
63+
// platforms = ["linux/amd64", "linux/arm64"]
64+
}

0 commit comments

Comments
 (0)