1919#
2020ARG BASE=debian:13.1-slim
2121
22- FROM $BASE AS build-layer
22+ FROM $BASE AS minimal
2323
2424ARG PG_REPO=https://git.postgresql.org/git/postgresql.git
2525ARG PG_BRANCH=master
2626ARG PG_MAJOR=19
2727
2828COPY build-deps.txt /
2929
30+ ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH
31+
3032# Install runtime and build dependencies
3133RUN apt-get update && \
32- apt-get install -y --no-install-recommends \
34+ apt-get install -y --no-install-recommends -o Dpkg::::= "--force-confdef" -o Dpkg::::= "--force-confold" \
3335 gnupg \
3436 dirmngr \
3537 ca-certificates \
3638 ssl-cert \
3739 libnss-wrapper \
3840 libgssapi-krb5-2 \
41+ libprotobuf-c1 \
42+ libnuma1 \
43+ liburing2 \
3944 libxml2 \
40- libllvm16 \
45+ libllvm19 \
4146 libxslt1.1 \
4247 xz-utils \
4348 zstd \
49+ libicu76 \
4450 postgresql-common \
45- $(cat /build-deps.txt) && \
46- rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
47-
48- RUN usermod -u 26 postgres
49-
50- ENV PG_MAJOR=$PG_MAJOR
51- ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH
52-
53- # Build PostgreSQL
54- # Partially refer to https://github.com/docker-library/postgres/blob/master/16/alpine3.21/Dockerfile#L119-L159
55- RUN mkdir -p /usr/src/postgresql && \
51+ $(cat /build-deps.txt) \
52+ && \
53+ usermod -u 26 postgres && \
54+ # Build PostgreSQL
55+ mkdir -p /usr/src/postgresql && \
5656 git clone -b "$PG_BRANCH" --single-branch "$PG_REPO" /usr/src/postgresql && \
5757 cd /usr/src/postgresql && \
58- export LLVM_CONFIG="/usr/lib/llvm-16 /bin/llvm-config" && \
59- export CLANG=clang-16 && \
58+ export LLVM_CONFIG="/usr/lib/llvm-19 /bin/llvm-config" && \
59+ export CLANG=clang-19 && \
6060 ./configure \
6161 --build=x86_64-linux-gnu \
6262 --prefix=/usr \
@@ -86,6 +86,8 @@ RUN mkdir -p /usr/src/postgresql && \
8686 --with-systemd \
8787 --with-selinux \
8888 --with-zstd \
89+ --with-liburing \
90+ --with-libnuma \
8991 --with-extra-version=-$(git rev-parse --short HEAD) \
9092 --datarootdir=/usr/share/ \
9193 --infodir=/usr/share/info \
@@ -105,46 +107,59 @@ RUN mkdir -p /usr/src/postgresql && \
105107 && \
106108 make -j "$(nproc)" world-bin && \
107109 make install-world-bin && \
108- rm -rf /usr/src/postgresql
109-
110- # DoD 2.3 - remove setuid/setgid from any binary that not strictly requires it, and before doing that list them on the stdout
111- RUN find / -not -path "/proc/*" -perm /6000 -type f -exec ls -ld {} \; -exec chmod a-s {} \; || true
110+ apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
111+ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
112+ rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /usr/src/postgresql
112113
113-
114- FROM build-layer AS minimal
115- RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
116- rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
117114USER 26
118115
119- FROM build-layer AS standard
120- # TODO: re-enable once https://github.com/pgaudit/pgaudit/issues/257 is fixed
116+ FROM minimal AS standard
117+ USER root
118+
121119# Build PgAudit
122120# See to https://github.com/pgaudit/pgaudit/blob/master/README.md#compile-and-install
123- # RUN mkdir -p /usr/src/pgaudit && \
121+ # TODO: uncomment when https://github.com/pgaudit/pgaudit/issues/257 is fixed
122+ # RUN apt-get update && \
123+ # apt-get install -y --no-install-recommends \
124+ # build-essential \
125+ # git \
126+ # libssl-dev \
127+ # libkrb5-dev \
128+ # && \
129+ # mkdir -p /usr/src/pgaudit && \
124130# git clone -b main --single-branch https://github.com/pgaudit/pgaudit.git /usr/src/pgaudit && \
125131# cd /usr/src/pgaudit && \
126132# make install USE_PGXS=1 PG_CONFIG=/usr/lib/postgresql/$PG_MAJOR/bin/pg_config && \
127- # rm -rf /usr/src/pgaudit
133+ # apt-get purge -y --auto-remove \
134+ # build-essential \
135+ # git \
136+ # libssl-dev \
137+ # libkrb5-dev \
138+ # && \
139+ # apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
140+ # rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /usr/src/pgaudit
128141
129142# Install all locales
130143RUN apt-get update && \
131- apt-get install -y --no-install-recommends locales-all
132-
133- RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
144+ apt-get install -y --no-install-recommends locales-all && \
134145 rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
146+
135147USER 26
136148
137- FROM build-layer AS postgis
149+ FROM standard AS postgis
150+ USER root
138151ARG POSTGIS_REPO=https://github.com/postgis/postgis.git
139152ARG POSTGIS_BRANCH=master
140153
141154RUN apt-get update && \
142155 apt-get install -y --no-install-recommends \
156+ $(cat /build-deps.txt) \
157+ # runtime deps
143158 libproj25 \
144159 libpq5 \
145- libgdal32 \
146- libgeos-c1v5 \
147- libsfcgal1 \
160+ libgdal36 \
161+ libgeos-c1t64 \
162+ libsfcgal2 \
148163 && \
149164 mkdir -p /usr/src/postgis && \
150165 git clone -b "$POSTGIS_BRANCH" --single-branch "$POSTGIS_REPO" /usr/src/postgis && \
@@ -153,8 +168,8 @@ RUN apt-get update && \
153168 ./configure --with-pgconfig=/usr/lib/postgresql/$PG_MAJOR/bin/pg_config --with-sfcgal && \
154169 make -j$(nproc) && \
155170 make install && \
156- rm -rf /usr/src/postgis
171+ apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
172+ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
173+ rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /usr/src/postgis
157174
158- RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
159- rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
160175USER 26
0 commit comments