From 52ada1154bf141fcef8af56272a4f3ea85b18798 Mon Sep 17 00:00:00 2001 From: Alexander Kerkum Date: Tue, 11 Nov 2025 18:09:24 +0100 Subject: [PATCH 1/3] Add Dockerfile for 16-3.4 --- 16-3.4/Dockerfile | 35 +++++++++++++++++++++++++++++++++++ 16-3.4/initdb-postgis.sh | 25 +++++++++++++++++++++++++ 16-3.4/pgarchive.list | 1 + 16-3.4/update-postgis.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 16-3.4/Dockerfile create mode 100644 16-3.4/initdb-postgis.sh create mode 100644 16-3.4/pgarchive.list create mode 100755 16-3.4/update-postgis.sh diff --git a/16-3.4/Dockerfile b/16-3.4/Dockerfile new file mode 100644 index 000000000..69b1c3426 --- /dev/null +++ b/16-3.4/Dockerfile @@ -0,0 +1,35 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM postgres:16-bullseye + +LABEL maintainer="PostGIS Project - https://postgis.net" \ + org.opencontainers.image.description="PostGIS 3.4 spatial database extension with PostgreSQL 16 bullseye" \ + org.opencontainers.image.source="https://github.com/postgis/docker-postgis" + +ENV POSTGIS_MAJOR=3 +ENV POSTGIS_VERSION=3.4.3+dfsg-2.pgdg110+1 + +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates software-properties-common wget \ + && wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ + && add-apt-repository "deb https://apt-archive.postgresql.org/pub/repos/apt/ bullseye-pgdg-archive main 16" + #&& add-apt-repository "deb [ signed-by=/usr/local/share/keyrings/postgres.gpg.asc ] http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main 16" \ + + +RUN apt-get update \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + diff --git a/16-3.4/initdb-postgis.sh b/16-3.4/initdb-postgis.sh new file mode 100644 index 000000000..e38ad7d66 --- /dev/null +++ b/16-3.4/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<- 'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.4/pgarchive.list b/16-3.4/pgarchive.list new file mode 100644 index 000000000..767e00769 --- /dev/null +++ b/16-3.4/pgarchive.list @@ -0,0 +1 @@ +deb https://apt-archive.postgresql.org/pub/repos/apt/ bullseye-pgdg-archive main 16 diff --git a/16-3.4/update-postgis.sh b/16-3.4/update-postgis.sh new file mode 100755 index 000000000..3e60e3983 --- /dev/null +++ b/16-3.4/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done From adcd0f7161b7628f13b41a46a952a3fb6e3925a6 Mon Sep 17 00:00:00 2001 From: Alexander Kerkum Date: Tue, 11 Nov 2025 18:11:10 +0100 Subject: [PATCH 2/3] Cleaning up --- 16-3.4/Dockerfile | 1 - 16-3.4/pgarchive.list | 1 - 2 files changed, 2 deletions(-) delete mode 100644 16-3.4/pgarchive.list diff --git a/16-3.4/Dockerfile b/16-3.4/Dockerfile index 69b1c3426..547a23a71 100644 --- a/16-3.4/Dockerfile +++ b/16-3.4/Dockerfile @@ -15,7 +15,6 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates software-properties-common wget \ && wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ && add-apt-repository "deb https://apt-archive.postgresql.org/pub/repos/apt/ bullseye-pgdg-archive main 16" - #&& add-apt-repository "deb [ signed-by=/usr/local/share/keyrings/postgres.gpg.asc ] http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main 16" \ RUN apt-get update \ diff --git a/16-3.4/pgarchive.list b/16-3.4/pgarchive.list deleted file mode 100644 index 767e00769..000000000 --- a/16-3.4/pgarchive.list +++ /dev/null @@ -1 +0,0 @@ -deb https://apt-archive.postgresql.org/pub/repos/apt/ bullseye-pgdg-archive main 16 From 7661f5d71013216a22129b846e3eb20d66338e47 Mon Sep 17 00:00:00 2001 From: Jan Pieter Waagmeester Date: Wed, 12 Nov 2025 10:35:15 +0100 Subject: [PATCH 3/3] Build from source --- 16-3.4/Dockerfile | 62 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/16-3.4/Dockerfile b/16-3.4/Dockerfile index 547a23a71..d12194b9c 100644 --- a/16-3.4/Dockerfile +++ b/16-3.4/Dockerfile @@ -1,33 +1,57 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - +# Base image: PostgreSQL 16 on Bullseye (amd64/arm64) FROM postgres:16-bullseye LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4 spatial database extension with PostgreSQL 16 bullseye" \ + org.opencontainers.image.description="PostGIS 3.4.3 spatial extension with PostgreSQL 16, built from source" \ org.opencontainers.image.source="https://github.com/postgis/docker-postgis" ENV POSTGIS_MAJOR=3 -ENV POSTGIS_VERSION=3.4.3+dfsg-2.pgdg110+1 - -RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates software-properties-common wget \ - && wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ - && add-apt-repository "deb https://apt-archive.postgresql.org/pub/repos/apt/ bullseye-pgdg-archive main 16" - +ENV POSTGIS_VERSION=3.4.3 +ENV PG_MAJOR=16 +# Install build dependencies for PostGIS RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + build-essential \ + ca-certificates \ + wget \ + curl \ + gnupg \ + software-properties-common \ + autoconf \ + automake \ + libtool \ + pkg-config \ + libxml2-dev \ + libgeos-dev \ + libproj-dev \ + libgdal-dev \ + libjson-c-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libcurl4-openssl-dev \ + libreadline-dev \ + liblzma-dev \ + libpcre2-dev \ + bison \ + flex \ + postgresql-server-dev-$PG_MAJOR \ && rm -rf /var/lib/apt/lists/* +# Download and build PostGIS 3.4.3 from source +WORKDIR /usr/src +RUN wget -qO postgis.tar.gz "https://download.osgeo.org/postgis/source/postgis-$POSTGIS_VERSION.tar.gz" \ + && tar xzf postgis.tar.gz \ + && rm postgis.tar.gz \ + && cd postgis-$POSTGIS_VERSION \ + && ./configure --with-pgconfig=/usr/lib/postgresql/$PG_MAJOR/bin/pg_config --without-protobuf \ + && make \ + && make install + +# Clean up source directory +RUN rm -rf /usr/src/postgis-$POSTGIS_VERSION + +# Init scripts directory RUN mkdir -p /docker-entrypoint-initdb.d COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh COPY ./update-postgis.sh /usr/local/bin