@@ -7,8 +7,8 @@ FROM ${BASE_IMAGE_OS}:${BASE_IMAGE_TAG} AS dev_base
77ARG BASE_IMAGE_OS
88ARG BASE_IMAGE_TAG
99
10- # Build arguments (can be overridden at build time)
11- ARG PG_MAJOR=18
10+ # Set environment variables for non-interactive installations and PostgreSQL/PostGIS versions
11+ ENV PG_LAKE_REF=main
1212ARG PG16_VERSION=16.10
1313ARG PG17_VERSION=17.6
1414ARG PG18_VERSION=18.0
@@ -17,10 +17,6 @@ ARG PGAUDIT16_VERSION=REL_16_STABLE
1717ARG PGAUDIT17_VERSION=REL_17_STABLE
1818ARG PGAUDIT18_VERSION=REL_18_STABLE
1919
20- # Set environment variables from build args
21- ENV PG_MAJOR=${PG_MAJOR}
22- ENV PG_LAKE_REF=main
23-
2420# Install build dependencies
2521RUN if [ "$BASE_IMAGE_OS" = "almalinux" ]; then \
2622 dnf -y update && \
@@ -159,78 +155,99 @@ RUN echo "postgres ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/postgres
159155USER 1001:1001
160156WORKDIR /home/postgres
161157
162- # Set PostgreSQL version variables based on PG_MAJOR
163- RUN if [ "$PG_MAJOR" = "16" ]; then \
164- echo "export PG_VERSION=$PG16_VERSION" >> ~/.pgenv; \
165- echo "export PGAUDIT_VERSION=$PGAUDIT16_VERSION" >> ~/.pgenv; \
166- echo "export PG_COMPILE_FLAGS='--enable-debug --enable-cassert --enable-depend --with-openssl --with-libxml --with-libxslt --with-icu --with-uuid=ossp --with-lz4'" >> ~/.pgenv; \
167- elif [ "$PG_MAJOR" = "17" ]; then \
168- echo "export PG_VERSION=$PG17_VERSION" >> ~/.pgenv; \
169- echo "export PGAUDIT_VERSION=$PGAUDIT17_VERSION" >> ~/.pgenv; \
170- echo "export PG_COMPILE_FLAGS='--enable-debug --enable-depend --with-openssl --with-libxml --with-libxslt --with-icu --with-uuid=ossp --with-lz4 --enable-injection-points'" >> ~/.pgenv; \
171- elif [ "$PG_MAJOR" = "18" ]; then \
172- echo "export PG_VERSION=$PG18_VERSION" >> ~/.pgenv; \
173- echo "export PGAUDIT_VERSION=$PGAUDIT18_VERSION" >> ~/.pgenv; \
174- echo "export PG_COMPILE_FLAGS='--enable-debug --enable-depend --with-openssl --with-libxml --with-libxslt --with-icu --with-uuid=ossp --with-lz4 --enable-injection-points'" >> ~/.pgenv; \
175- fi && \
176- . ~/.pgenv && \
177- wget https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.gz && \
158+ # Download PostgreSQL 16, 17, 18, PostGIS
159+ RUN wget https://ftp.postgresql.org/pub/source/v$PG16_VERSION/postgresql-$PG16_VERSION.tar.gz && \
160+ wget https://ftp.postgresql.org/pub/source/v$PG17_VERSION/postgresql-$PG17_VERSION.tar.gz && \
161+ wget https://ftp.postgresql.org/pub/source/v$PG18_VERSION/postgresql-$PG18_VERSION.tar.gz && \
178162 wget https://download.osgeo.org/postgis/source/postgis-$POSTGIS_VERSION.tar.gz && \
179- wget https://github.com/pgaudit/pgaudit/archive/refs/heads/$PGAUDIT_VERSION.tar.gz && \
180- tar -xzf postgresql-$PG_VERSION.tar.gz && rm postgresql-$PG_VERSION.tar.gz && \
181- tar -xzf $PGAUDIT_VERSION.tar.gz && rm $PGAUDIT_VERSION.tar.gz && \
163+ wget https://github.com/pgaudit/pgaudit/archive/refs/heads/$PGAUDIT16_VERSION.tar.gz && \
164+ wget https://github.com/pgaudit/pgaudit/archive/refs/heads/$PGAUDIT17_VERSION.tar.gz && \
165+ wget https://github.com/pgaudit/pgaudit/archive/refs/heads/$PGAUDIT18_VERSION.tar.gz && \
166+ tar -xzf postgresql-$PG16_VERSION.tar.gz && rm postgresql-$PG16_VERSION.tar.gz && \
167+ tar -xzf postgresql-$PG17_VERSION.tar.gz && rm postgresql-$PG17_VERSION.tar.gz && \
168+ tar -xzf postgresql-$PG18_VERSION.tar.gz && rm postgresql-$PG18_VERSION.tar.gz && \
169+ tar -xzf $PGAUDIT16_VERSION.tar.gz && rm $PGAUDIT16_VERSION.tar.gz && \
170+ tar -xzf $PGAUDIT17_VERSION.tar.gz && rm $PGAUDIT17_VERSION.tar.gz && \
171+ tar -xzf $PGAUDIT18_VERSION.tar.gz && rm $PGAUDIT18_VERSION.tar.gz && \
182172 tar -xzf postgis-$POSTGIS_VERSION.tar.gz && rm postgis-$POSTGIS_VERSION.tar.gz
183173
174+ ARG PG_COMPILE_FLAGS_16="--enable-debug --enable-cassert --enable-depend --with-openssl --with-libxml --with-libxslt --with-icu --with-uuid=ossp --with-lz4"
175+ # PG 17-18 have asserts disabled
176+ ARG PG_COMPILE_FLAGS_17="--enable-debug --enable-depend --with-openssl --with-libxml --with-libxslt --with-icu --with-uuid=ossp --with-lz4 --enable-injection-points"
177+ ARG PG_COMPILE_FLAGS_18="--enable-debug --enable-depend --with-openssl --with-libxml --with-libxslt --with-icu --with-uuid=ossp --with-lz4 --enable-injection-points"
184178ENV PGBASEDIR=/home/postgres
185179
186- # Compile and install PostgreSQL for the selected major version
187- RUN . ~/.pgenv && \
188- cd postgresql-$PG_VERSION && \
189- ./configure --prefix=$PGBASEDIR/pgsql-$PG_MAJOR $PG_COMPILE_FLAGS && \
180+ # Compile and install PostgreSQL 16 with pgindent
181+ RUN cd postgresql-$PG16_VERSION && \
182+ ./configure --prefix=$PGBASEDIR/pgsql-16 $PG_COMPILE_FLAGS_16 && \
190183 make -j `nproc` install && \
191184 make -C src/test/isolation install && \
192- (if [ "$PG_MAJOR" != "16" ]; then make -C src/test/modules/injection_points install; fi) && \
193185 make -j `nproc` -C src/tools/pg_bsd_indent install && \
194- cp src/tools/pgindent/pgindent $PGBASEDIR/pgsql-$PG_MAJOR /bin/ && \
195- cp src/tools/pgindent/typedefs.list $PGBASEDIR/pgsql-$PG_MAJOR /share/ && \
196- mkdir -pv $PGBASEDIR/pgsql-$PG_MAJOR /regress && cp -r src/test/regress/* $PGBASEDIR/pgsql-$PG_MAJOR /regress && \
186+ cp src/tools/pgindent/pgindent $PGBASEDIR/pgsql-16 /bin/ && \
187+ cp src/tools/pgindent/typedefs.list $PGBASEDIR/pgsql-16 /share/ && \
188+ mkdir -pv $PGBASEDIR/pgsql-16 /regress && cp -r src/test/regress/* $PGBASEDIR/pgsql-16 /regress && \
197189 (cd contrib && make -j `nproc` install) && \
198- cd .. && rm -rf postgresql-$PG_VERSION *
190+ cd .. && rm -rf postgresql-$PG16_VERSION *
199191
200- # Compile and install PG AUDIT for the selected major version
201- RUN . ~/.pgenv && \
202- cd pgaudit-$PGAUDIT_VERSION && \
203- make -j `nproc` install USE_PGXS=1 PG_CONFIG=$PGBASEDIR/pgsql-$PG_MAJOR/bin/pg_config && \
204- cd .. && rm -rf pgaudit-$PGAUDIT_VERSION*
192+ # Compile and install PostgreSQL 17 with pgindent
193+ RUN cd postgresql-$PG17_VERSION && \
194+ ./configure --prefix=$PGBASEDIR/pgsql-17 $PG_COMPILE_FLAGS_17 && \
195+ make -j `nproc` && make install && \
196+ make -C src/test/isolation install && \
197+ make -C src/test/modules/injection_points install && \
198+ make -j `nproc` -C src/tools/pg_bsd_indent install && \
199+ cp src/tools/pgindent/pgindent $PGBASEDIR/pgsql-17/bin/ && \
200+ cp src/tools/pgindent/typedefs.list $PGBASEDIR/pgsql-17/share/ && \
201+ mkdir -pv $PGBASEDIR/pgsql-17/regress && cp -r src/test/regress/* $PGBASEDIR/pgsql-17/regress && \
202+ (cd contrib && make -j `nproc` install) && \
203+ cd .. && rm -rf postgresql-$PG17_VERSION*
205204
206- # Compile and install PostGIS for the selected major version
207- RUN cd postgis-$POSTGIS_VERSION && \
208- ./configure --prefix=$PGBASEDIR/pgsql-$PG_MAJOR/ --with-pgconfig=$PGBASEDIR/pgsql-$PG_MAJOR/bin/pg_config && \
205+ # Compile and install PostgreSQL 18 with pgindent
206+ RUN cd postgresql-$PG18_VERSION && \
207+ ./configure --prefix=$PGBASEDIR/pgsql-18 $PG_COMPILE_FLAGS_18 && \
209208 make -j `nproc` && make install && \
209+ make -C src/test/isolation install && \
210+ make -C src/test/modules/injection_points install && \
211+ make -j `nproc` -C src/tools/pg_bsd_indent install && \
212+ cp src/tools/pgindent/pgindent $PGBASEDIR/pgsql-18/bin/ && \
213+ cp src/tools/pgindent/typedefs.list $PGBASEDIR/pgsql-18/share/ && \
214+ mkdir -pv $PGBASEDIR/pgsql-18/regress && cp -r src/test/regress/* $PGBASEDIR/pgsql-18/regress && \
215+ (cd contrib && make -j `nproc` install) && \
216+ cd .. && rm -rf postgresql-$PG18_VERSION*
217+
218+ # Compile and install PG AUDIT 16
219+ RUN cd pgaudit-$PGAUDIT16_VERSION && \
220+ make -j `nproc` install USE_PGXS=1 PG_CONFIG=$PGBASEDIR/pgsql-16/bin/pg_config
221+
222+ # Compile and install PG AUDIT 17
223+ RUN cd pgaudit-$PGAUDIT17_VERSION && \
224+ make -j `nproc` install USE_PGXS=1 PG_CONFIG=$PGBASEDIR/pgsql-17/bin/pg_config
225+
226+ # Compile and install PG AUDIT 18
227+ RUN cd pgaudit-$PGAUDIT18_VERSION && \
228+ make -j `nproc` install USE_PGXS=1 PG_CONFIG=$PGBASEDIR/pgsql-18/bin/pg_config
229+
230+ # Compile and install PostGIS
231+ RUN cd postgis-$POSTGIS_VERSION && \
232+ ./configure --prefix=$PGBASEDIR/pgsql-16/ --with-pgconfig=$PGBASEDIR/pgsql-16/bin/pg_config && make -j `nproc` && make install && make clean && \
233+ ./configure --prefix=$PGBASEDIR/pgsql-17/ --with-pgconfig=$PGBASEDIR/pgsql-17/bin/pg_config && make -j `nproc` && make install && make clean && \
234+ ./configure --prefix=$PGBASEDIR/pgsql-18/ --with-pgconfig=$PGBASEDIR/pgsql-18/bin/pg_config && make -j `nproc` && make install && make clean && \
210235 cd .. && rm -rf postgis-$POSTGIS_VERSION*
211236
212- # Compile and install pg_cron for the selected major version
237+ # Compile and install pg_cron
213238RUN git clone https://github.com/citusdata/pg_cron.git && \
214239 cd pg_cron && \
215- make install PG_CONFIG=$PGBASEDIR/pgsql-$PG_MAJOR/bin/pg_config && \
240+ make install PG_CONFIG=$PGBASEDIR/pgsql-16/bin/pg_config && make clean PG_CONFIG=$PGBASEDIR/pgsql-16/bin/pg_config && \
241+ make install PG_CONFIG=$PGBASEDIR/pgsql-17/bin/pg_config && make clean PG_CONFIG=$PGBASEDIR/pgsql-17/bin/pg_config && \
242+ make install PG_CONFIG=$PGBASEDIR/pgsql-18/bin/pg_config && make clean PG_CONFIG=$PGBASEDIR/pgsql-18/bin/pg_config && \
216243 cd .. && rm -rf pg_cron
217244
218- ENV PATH=/home/postgres/pgsql-$PG_MAJOR/bin:$PATH
219-
220245# Install vcpkg as postgres user
221246ARG VCPKG_VERSION=2025.01.13
222247
223- # Set environment variables to help with download issues
224- ENV VCPKG_FORCE_SYSTEM_BINARIES=1
225- ENV VCPKG_MAX_CONCURRENCY=1
226-
227248RUN git clone https://github.com/Microsoft/vcpkg.git -b $VCPKG_VERSION /home/postgres/vcpkg && \
228249 ./vcpkg/bootstrap-vcpkg.sh && \
229- # Install packages with retry logic for network issues
230- (./vcpkg/vcpkg install azure-identity-cpp azure-storage-blobs-cpp azure-storage-files-datalake-cpp openssl || \
231- (echo "Retrying vcpkg install after network error..." && sleep 5 && \
232- ./vcpkg/vcpkg install azure-identity-cpp azure-storage-blobs-cpp azure-storage-files-datalake-cpp openssl)) && \
233- rm -rf /home/postgres/vcpkg/buildtrees /home/postgres/vcpkg/downloads
250+ ./vcpkg/vcpkg install azure-identity-cpp azure-storage-blobs-cpp azure-storage-files-datalake-cpp openssl
234251
235252ENV VCPKG_TOOLCHAIN_PATH="/home/postgres/vcpkg/scripts/buildsystems/vcpkg.cmake"
236253
@@ -244,28 +261,41 @@ RUN git clone https://github.com/snowflake-labs/pg_lake.git \
244261# ############# pg_lake_builder - Build all pg_lake extensions ##############
245262FROM base AS pg_lake_builder
246263
264+ # need to redefine ARGs in each stage
265+ ARG PG_MAJOR=18
266+
267+ # Set environment variables for the selected PostgreSQL version
268+ ENV PG_MAJOR=${PG_MAJOR}
269+ ENV PATH=/home/postgres/pgsql-${PG_MAJOR}/bin:$PATH
270+
247271# Install pg_lake extensions (build happens here, not in final image)
248272RUN cd pg_lake && \
249- make install-pg_extension_base && \
250- make install-pg_map && \
251- make install-pg_extension_updater && \
252- make install-pg_lake_engine && \
253- make install-avro && \
254- make install-pg_lake_iceberg && \
255- make install-pg_lake_table && \
256- make install-pg_lake_spatial && \
257- make install-pg_lake_copy && \
258- make install-pg_lake && \
259- make install-pg_lake_benchmark
273+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_extension_base && \
274+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_map && \
275+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_extension_updater && \
276+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_lake_engine && \
277+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-avro && \
278+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_lake_iceberg && \
279+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_lake_table && \
280+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_lake_spatial && \
281+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_lake_copy && \
282+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_lake && \
283+ PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make install-pg_lake_benchmark
260284
261285# ############# pgduck_builder - Build duckdb_pglake and pgduck_server ##############
262286FROM base AS pgduck_builder
263287
288+ # need to redefine ARGs in each stage
289+ ARG PG_MAJOR=18
264290ARG PGCOMPAT_BUILD_CONFIG=Release
265291
292+ # Set environment variables for the selected PostgreSQL version
293+ ENV PG_MAJOR=${PG_MAJOR}
294+ ENV PATH=/home/postgres/pgsql-${PG_MAJOR}/bin:$PATH
295+
266296# Install pgduck_server (build happens here, not in final image)
267- RUN cd pg_lake/duckdb_pglake && make && make install && rm -r build
268- RUN cd pg_lake/pgduck_server && make && make install
297+ RUN cd pg_lake/duckdb_pglake && PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make && make install && rm -r build
298+ RUN cd pg_lake/pgduck_server && PG_CONFIG=/home/postgres/pgsql-${PG_MAJOR}/bin/pg_config make && make install
269299
270300# ############# runtime_base - Minimal runtime environment ##############
271301ARG BASE_IMAGE_OS="almalinux"
@@ -275,7 +305,6 @@ FROM ${BASE_IMAGE_OS}:${BASE_IMAGE_TAG} AS runtime_base
275305# need to redefine ARGs in each stage
276306ARG BASE_IMAGE_OS
277307ARG BASE_IMAGE_TAG
278- ARG PG_MAJOR=18
279308
280309# Install ONLY runtime libraries (no -devel packages, no build tools)
281310RUN if [ "$BASE_IMAGE_OS" = "almalinux" ]; then \
@@ -341,13 +370,17 @@ USER 1001:1001
341370WORKDIR /home/postgres
342371
343372ENV PGBASEDIR=/home/postgres
344- ENV PATH=/home/postgres/pgsql-$PG_MAJOR/bin:$PATH
345373
346374# ############# pg_lake_postgres - Final runtime image (COPY ONLY) ##############
347375FROM runtime_base AS pg_lake_postgres
348376
377+ # need to redefine ARGs in each stage
349378ARG PG_MAJOR=18
350379
380+ # Set environment variables for runtime
381+ ENV PG_MAJOR=${PG_MAJOR}
382+ ENV PATH=/home/postgres/pgsql-${PG_MAJOR}/bin:$PATH
383+
351384# Copy PostgreSQL binaries and libraries for the selected version from dev_base
352385COPY --from=dev_base --chown=postgres:postgres /home/postgres/pgsql-${PG_MAJOR} /home/postgres/pgsql-${PG_MAJOR}
353386
@@ -357,13 +390,18 @@ COPY --from=pg_lake_builder --chown=postgres:postgres /home/postgres/pgsql-${PG_
357390COPY --from=pg_lake_builder --chown=postgres:postgres /home/postgres/pgsql-${PG_MAJOR}/share /home/postgres/pgsql-${PG_MAJOR}/share
358391
359392# Initialize database (lightweight operation, doesn't compile anything)
360- RUN initdb -D $PGBASEDIR/pgsql-$PG_MAJOR/data -U postgres --locale=C.UTF-8 --data-checksums
393+ RUN initdb -D $PGBASEDIR/pgsql-${ PG_MAJOR} /data -U postgres --locale=C.UTF-8 --data-checksums
361394
362395# ############# pgduck_server - Final runtime image (COPY ONLY) ##############
363396FROM runtime_base AS pgduck_server
364397
398+ # need to redefine ARGs in each stage
365399ARG PG_MAJOR=18
366400
401+ # Set environment variables for runtime
402+ ENV PG_MAJOR=${PG_MAJOR}
403+ ENV PATH=/home/postgres/pgsql-${PG_MAJOR}/bin:$PATH
404+
367405# Copy PostgreSQL binaries and libraries for the selected version
368406COPY --from=dev_base --chown=postgres:postgres /home/postgres/pgsql-${PG_MAJOR}/bin /home/postgres/pgsql-${PG_MAJOR}/bin
369407COPY --from=dev_base --chown=postgres:postgres /home/postgres/pgsql-${PG_MAJOR}/lib /home/postgres/pgsql-${PG_MAJOR}/lib
0 commit comments