├── .circleci └── config.yml ├── .coderabbit.yaml ├── .dockerignore ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .travis.yml.disabled ├── 13-3.5 ├── Dockerfile ├── alpine │ ├── Dockerfile │ ├── initdb-postgis.sh │ └── update-postgis.sh ├── initdb-postgis.sh └── update-postgis.sh ├── 14-3.5 ├── Dockerfile ├── alpine │ ├── Dockerfile │ ├── initdb-postgis.sh │ └── update-postgis.sh ├── initdb-postgis.sh └── update-postgis.sh ├── 15-3.5 ├── Dockerfile ├── alpine │ ├── Dockerfile │ ├── initdb-postgis.sh │ └── update-postgis.sh ├── initdb-postgis.sh └── update-postgis.sh ├── 16-3.5 ├── Dockerfile ├── alpine │ ├── Dockerfile │ ├── initdb-postgis.sh │ └── update-postgis.sh ├── initdb-postgis.sh └── update-postgis.sh ├── 16-master ├── Dockerfile ├── initdb-postgis.sh └── update-postgis.sh ├── 17-3.5 ├── Dockerfile ├── alpine │ ├── Dockerfile │ ├── initdb-postgis.sh │ └── update-postgis.sh ├── initdb-postgis.sh └── update-postgis.sh ├── 17-3.6.0alpha1 ├── Dockerfile └── alpine │ ├── Dockerfile │ ├── initdb-postgis.sh │ └── update-postgis.sh ├── 17-master ├── Dockerfile ├── initdb-postgis.sh └── update-postgis.sh ├── AUTHORS ├── Dockerfile.alpine.template ├── Dockerfile.master.template ├── Dockerfile.template ├── LICENSE ├── Makefile ├── README.md ├── examples └── image-with-postgis-clis │ ├── Dockerfile │ └── README.md ├── initdb-postgis.sh ├── test ├── postgis-config.sh └── tests │ └── postgis-basics │ └── run.sh ├── update-postgis.sh └── update.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | jobs: 4 | # build: 5 | # docker: 6 | # - image: cimg/base:stable 7 | # steps: 8 | # - checkout 9 | # - run: echo "This job is configured but will never run because it's commented out." 10 | 11 | workflows: 12 | # version: 2 13 | # build_and_test: 14 | # jobs: 15 | # - build 16 | 17 | # This config file is a placeholder and does not define any active jobs or workflows. 18 | -------------------------------------------------------------------------------- /.coderabbit.yaml: -------------------------------------------------------------------------------- 1 | # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json 2 | # see - https://docs.coderabbit.ai/configure-coderabbit/ 3 | 4 | language: "en-US" 5 | 6 | early_access: true 7 | 8 | # we(docker-postgis) always need a human to approve (and merge), we don't use this, 9 | reviews: 10 | profile: "chill" 11 | request_changes_workflow: false 12 | high_level_summary: false 13 | poem: false 14 | review_status: false 15 | collapse_walkthrough: true 16 | auto_review: 17 | enabled: false 18 | drafts: false 19 | 20 | # chat is allowed 21 | chat: 22 | auto_reply: true 23 | 24 | 25 | # https://docs.coderabbit.ai/guides/commands 26 | # 27 | # The following commands are available (invoked as PR comments): 28 | # @coderabbitai pause : to pause the reviews on a PR. 29 | # @coderabbitai resume : to resume the paused reviews. 30 | # @coderabbitai review : to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. 31 | # @coderabbitai full review : to do a full review from scratch and review all the files again. 32 | # @coderabbitai summary : to regenerate the summary of the PR. 33 | # @coderabbitai resolve : resolve all the CodeRabbit review comments. 34 | # @coderabbitai configuration : to show the current CodeRabbit configuration for the repository. 35 | # @coderabbitai help : to get help. 36 | 37 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | .git 3 | _* 4 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Docker PostGIS CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | - cron: '15 5 * * 1' 8 | 9 | defaults: 10 | run: 11 | shell: bash 12 | 13 | jobs: 14 | 15 | make-docker-images: 16 | strategy: 17 | matrix: 18 | runner-platform: ['ubuntu-24.04', 'ubuntu-24.04-arm'] 19 | postgres: [13, 14, 15, 16, 17] 20 | postgis: ['3.5'] 21 | variant: [default, alpine] 22 | include: 23 | - postgres: 16 24 | postgis: master 25 | variant: default 26 | runner-platform: 'ubuntu-24.04' 27 | - postgres: 17 28 | postgis: master 29 | variant: default 30 | runner-platform: 'ubuntu-24.04' 31 | - postgres: 16 32 | postgis: master 33 | variant: default 34 | runner-platform: 'ubuntu-24.04-arm' 35 | - postgres: 17 36 | postgis: master 37 | variant: default 38 | runner-platform: 'ubuntu-24.04-arm' 39 | - postgres: 17 40 | postgis: '3.6.0alpha1' 41 | variant: alpine 42 | runner-platform: 'ubuntu-24.04' 43 | - postgres: 17 44 | postgis: '3.6.0alpha1' 45 | variant: alpine 46 | runner-platform: 'ubuntu-24.04-arm' 47 | 48 | 49 | name: Build docker image for ${{ matrix.postgres }}-${{ matrix.postgis }} variant ${{ matrix.variant }} on ${{ matrix.runner-platform }} 50 | runs-on: ${{ matrix.runner-platform }} 51 | continue-on-error: ${{ matrix.postgis == 'master' }} 52 | env: 53 | VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }} 54 | VARIANT: ${{ matrix.variant }} 55 | DOCKER_APT_PKG_VER: '5:28.1.1-1~ubuntu.24.04~noble' 56 | 57 | steps: 58 | - name: Install/config specific version of Docker packages 59 | run: | 60 | echo "***** Removing any currently installed conflicting packages..." 61 | for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done 62 | echo "***** Setting up Docker's APT repo..." 63 | sudo apt-get update 64 | sudo apt-get install ca-certificates curl 65 | sudo install -m 0755 -d /etc/apt/keyrings 66 | sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 67 | sudo chmod a+r /etc/apt/keyrings/docker.asc 68 | echo \ 69 | "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ 70 | $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ 71 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 72 | sudo apt-get update 73 | echo "***** Check available docker-ce versions ." 74 | sudo apt policy docker-ce 75 | echo "***** Installing Docker packages..." 76 | sudo apt-get install docker-ce=${{ env.DOCKER_APT_PKG_VER }} docker-ce-cli=${{ env.DOCKER_APT_PKG_VER }} containerd.io docker-buildx-plugin docker-compose-plugin 77 | echo "***** Verifying initial Docker installation..." 78 | docker run hello-world 79 | echo "***** Displaying Docker information..." 80 | docker info 81 | echo "***** Configuring Docker for containerd image store..." 82 | echo "{ \"features\": { \"containerd-snapshotter\": true }}" | sudo tee /etc/docker/daemon.json 83 | sudo systemctl restart docker 84 | docker info -f '{{ .DriverStatus }}' 85 | 86 | - name: Load binfmt platforms for QEMU 87 | run: | 88 | docker run --privileged --rm tonistiigi/binfmt --install all 89 | docker images --tree 90 | 91 | - name: Checkout source 92 | uses: actions/checkout@v4 93 | 94 | - name: Build docker image for ${{ env.VERSION }} ${{ env.VARIANT }} 95 | run: make test 96 | 97 | - name: Login to dockerhub 98 | uses: docker/login-action@v3 99 | if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }} 100 | with: 101 | username: ${{ secrets.DOCKERHUB_USERNAME }} 102 | password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} 103 | 104 | - name: Push docker image to dockerhub 105 | # !!!! ONLY push the images when built on ubuntu-24.04 x86 runner for now, NOT for ubuntu-24.04-arm runners 106 | if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') && ( matrix.runner-platform == 'ubuntu-24.04' ) }} 107 | env: 108 | DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} 109 | DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} 110 | run: make push 111 | 112 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _* -------------------------------------------------------------------------------- /.travis.yml.disabled: -------------------------------------------------------------------------------- 1 | --- 2 | language: bash 3 | services: docker 4 | 5 | dist: xenial 6 | 7 | env: 8 | - VERSION=13-master 9 | - VERSION=13-3.0 10 | - VERSION=13-3.0 VARIANT=alpine 11 | - VERSION=12-master 12 | - VERSION=12-3.0 13 | - VERSION=12-3.0 VARIANT=alpine 14 | - VERSION=12-2.5 15 | - VERSION=12-2.5 VARIANT=alpine 16 | - VERSION=11-3.0 17 | - VERSION=11-3.0 VARIANT=alpine 18 | - VERSION=11-2.5 19 | - VERSION=11-2.5 VARIANT=alpine 20 | - VERSION=10-3.0 21 | - VERSION=10-3.0 VARIANT=alpine 22 | - VERSION=10-2.5 23 | - VERSION=10-2.5 VARIANT=alpine 24 | - VERSION=9.6-3.0 25 | - VERSION=9.6-3.0 VARIANT=alpine 26 | - VERSION=9.6-2.5 27 | - VERSION=9.6-2.5 VARIANT=alpine 28 | - VERSION=9.5-3.0 29 | - VERSION=9.5-3.0 VARIANT=alpine 30 | - VERSION=9.5-2.5 31 | - VERSION=9.5-2.5 VARIANT=alpine 32 | 33 | jobs: 34 | allow_failures: 35 | - env: VERSION=12-master 36 | - env: VERSION=13-master 37 | 38 | script: 39 | - if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_BRANCH" == "master" ]]; then 40 | echo "$DOCKERHUB_ACCESS_TOKEN" | docker login -u $DOCKERHUB_USERNAME --password-stdin && 41 | make push ; 42 | else 43 | make test ; 44 | fi 45 | -------------------------------------------------------------------------------- /13-3.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | 5 | FROM postgres:13-bullseye 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.2+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 13 bullseye" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_MAJOR 3 12 | ENV POSTGIS_VERSION 3.5.2+dfsg-1.pgdg110+1 13 | 14 | RUN apt-get update \ 15 | && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ 16 | && apt-get install -y --no-install-recommends \ 17 | # ca-certificates: for accessing remote raster files; 18 | # fix: https://github.com/postgis/docker-postgis/issues/307 19 | ca-certificates \ 20 | \ 21 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ 22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | RUN mkdir -p /docker-entrypoint-initdb.d 26 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 27 | COPY ./update-postgis.sh /usr/local/bin 28 | 29 | -------------------------------------------------------------------------------- /13-3.5/alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | ARG BASE_IMAGE=postgres:13-alpine3.22 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.3 spatial database extension with PostgreSQL 13 Alpine" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_VERSION 3.5.3 12 | ENV POSTGIS_SHA256 44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437 13 | 14 | RUN set -eux \ 15 | && apk add --no-cache --virtual .fetch-deps \ 16 | ca-certificates \ 17 | openssl \ 18 | tar \ 19 | \ 20 | && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ 21 | && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ 22 | && mkdir -p /usr/src/postgis \ 23 | && tar \ 24 | --extract \ 25 | --file postgis.tar.gz \ 26 | --directory /usr/src/postgis \ 27 | --strip-components 1 \ 28 | && rm postgis.tar.gz \ 29 | \ 30 | && apk add --no-cache --virtual .build-deps \ 31 | \ 32 | gdal-dev \ 33 | geos-dev \ 34 | proj-dev \ 35 | proj-util \ 36 | sfcgal-dev \ 37 | \ 38 | # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains 39 | # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. 40 | # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 41 | $DOCKER_PG_LLVM_DEPS \ 42 | \ 43 | autoconf \ 44 | automake \ 45 | cunit-dev \ 46 | file \ 47 | g++ \ 48 | gcc \ 49 | gettext-dev \ 50 | git \ 51 | json-c-dev \ 52 | libtool \ 53 | libxml2-dev \ 54 | make \ 55 | pcre2-dev \ 56 | perl \ 57 | protobuf-c-dev \ 58 | \ 59 | # build PostGIS - with Link Time Optimization (LTO) enabled 60 | && cd /usr/src/postgis \ 61 | && gettextize \ 62 | && ./autogen.sh \ 63 | && ./configure \ 64 | --enable-lto \ 65 | && make -j$(nproc) \ 66 | && make install \ 67 | \ 68 | # This section is for refreshing the proj data for the regression tests. 69 | # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 70 | # This increases the Docker image size by about 1 MB. 71 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 72 | && projsync --system-directory --file us_noaa_eshpgn \ 73 | && projsync --system-directory --file us_noaa_prvi \ 74 | && projsync --system-directory --file us_noaa_wmhpgn \ 75 | # This section performs a regression check. 76 | && mkdir /tempdb \ 77 | && chown -R postgres:postgres /tempdb \ 78 | && su postgres -c 'pg_ctl -D /tempdb init' \ 79 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 80 | && cd regress \ 81 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 82 | \ 83 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 84 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 85 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 86 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 87 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 88 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 89 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 90 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 91 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 92 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 93 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 94 | \ 95 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 96 | && rm -rf /tempdb \ 97 | && rm -rf /tmp/logfile \ 98 | && rm -rf /tmp/pgis_reg \ 99 | # add .postgis-rundeps 100 | && apk add --no-cache --virtual .postgis-rundeps \ 101 | \ 102 | gdal \ 103 | geos \ 104 | proj \ 105 | sfcgal \ 106 | \ 107 | json-c \ 108 | libstdc++ \ 109 | pcre2 \ 110 | protobuf-c \ 111 | \ 112 | # ca-certificates: for accessing remote raster files 113 | # fix https://github.com/postgis/docker-postgis/issues/307 114 | ca-certificates \ 115 | # clean 116 | && cd / \ 117 | && rm -rf /usr/src/postgis \ 118 | && apk del .fetch-deps .build-deps \ 119 | # At the end of the build, we print the collected information 120 | # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. 121 | && cat /_pgis_full_version.txt 122 | 123 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 124 | COPY ./update-postgis.sh /usr/local/bin 125 | -------------------------------------------------------------------------------- /13-3.5/alpine/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /13-3.5/alpine/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /13-3.5/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /13-3.5/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /14-3.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | 5 | FROM postgres:14-bullseye 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.2+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 14 bullseye" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_MAJOR 3 12 | ENV POSTGIS_VERSION 3.5.2+dfsg-1.pgdg110+1 13 | 14 | RUN apt-get update \ 15 | && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ 16 | && apt-get install -y --no-install-recommends \ 17 | # ca-certificates: for accessing remote raster files; 18 | # fix: https://github.com/postgis/docker-postgis/issues/307 19 | ca-certificates \ 20 | \ 21 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ 22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | RUN mkdir -p /docker-entrypoint-initdb.d 26 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 27 | COPY ./update-postgis.sh /usr/local/bin 28 | 29 | -------------------------------------------------------------------------------- /14-3.5/alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | ARG BASE_IMAGE=postgres:14-alpine3.22 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.3 spatial database extension with PostgreSQL 14 Alpine" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_VERSION 3.5.3 12 | ENV POSTGIS_SHA256 44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437 13 | 14 | RUN set -eux \ 15 | && apk add --no-cache --virtual .fetch-deps \ 16 | ca-certificates \ 17 | openssl \ 18 | tar \ 19 | \ 20 | && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ 21 | && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ 22 | && mkdir -p /usr/src/postgis \ 23 | && tar \ 24 | --extract \ 25 | --file postgis.tar.gz \ 26 | --directory /usr/src/postgis \ 27 | --strip-components 1 \ 28 | && rm postgis.tar.gz \ 29 | \ 30 | && apk add --no-cache --virtual .build-deps \ 31 | \ 32 | gdal-dev \ 33 | geos-dev \ 34 | proj-dev \ 35 | proj-util \ 36 | sfcgal-dev \ 37 | \ 38 | # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains 39 | # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. 40 | # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 41 | $DOCKER_PG_LLVM_DEPS \ 42 | \ 43 | autoconf \ 44 | automake \ 45 | cunit-dev \ 46 | file \ 47 | g++ \ 48 | gcc \ 49 | gettext-dev \ 50 | git \ 51 | json-c-dev \ 52 | libtool \ 53 | libxml2-dev \ 54 | make \ 55 | pcre2-dev \ 56 | perl \ 57 | protobuf-c-dev \ 58 | \ 59 | # build PostGIS - with Link Time Optimization (LTO) enabled 60 | && cd /usr/src/postgis \ 61 | && gettextize \ 62 | && ./autogen.sh \ 63 | && ./configure \ 64 | --enable-lto \ 65 | && make -j$(nproc) \ 66 | && make install \ 67 | \ 68 | # This section is for refreshing the proj data for the regression tests. 69 | # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 70 | # This increases the Docker image size by about 1 MB. 71 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 72 | && projsync --system-directory --file us_noaa_eshpgn \ 73 | && projsync --system-directory --file us_noaa_prvi \ 74 | && projsync --system-directory --file us_noaa_wmhpgn \ 75 | # This section performs a regression check. 76 | && mkdir /tempdb \ 77 | && chown -R postgres:postgres /tempdb \ 78 | && su postgres -c 'pg_ctl -D /tempdb init' \ 79 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 80 | && cd regress \ 81 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 82 | \ 83 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 84 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 85 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 86 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 87 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 88 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 89 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 90 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 91 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 92 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 93 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 94 | \ 95 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 96 | && rm -rf /tempdb \ 97 | && rm -rf /tmp/logfile \ 98 | && rm -rf /tmp/pgis_reg \ 99 | # add .postgis-rundeps 100 | && apk add --no-cache --virtual .postgis-rundeps \ 101 | \ 102 | gdal \ 103 | geos \ 104 | proj \ 105 | sfcgal \ 106 | \ 107 | json-c \ 108 | libstdc++ \ 109 | pcre2 \ 110 | protobuf-c \ 111 | \ 112 | # ca-certificates: for accessing remote raster files 113 | # fix https://github.com/postgis/docker-postgis/issues/307 114 | ca-certificates \ 115 | # clean 116 | && cd / \ 117 | && rm -rf /usr/src/postgis \ 118 | && apk del .fetch-deps .build-deps \ 119 | # At the end of the build, we print the collected information 120 | # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. 121 | && cat /_pgis_full_version.txt 122 | 123 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 124 | COPY ./update-postgis.sh /usr/local/bin 125 | -------------------------------------------------------------------------------- /14-3.5/alpine/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /14-3.5/alpine/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /14-3.5/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /14-3.5/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /15-3.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | 5 | FROM postgres:15-bullseye 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.2+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 15 bullseye" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_MAJOR 3 12 | ENV POSTGIS_VERSION 3.5.2+dfsg-1.pgdg110+1 13 | 14 | RUN apt-get update \ 15 | && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ 16 | && apt-get install -y --no-install-recommends \ 17 | # ca-certificates: for accessing remote raster files; 18 | # fix: https://github.com/postgis/docker-postgis/issues/307 19 | ca-certificates \ 20 | \ 21 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ 22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | RUN mkdir -p /docker-entrypoint-initdb.d 26 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 27 | COPY ./update-postgis.sh /usr/local/bin 28 | 29 | -------------------------------------------------------------------------------- /15-3.5/alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | ARG BASE_IMAGE=postgres:15-alpine3.22 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.3 spatial database extension with PostgreSQL 15 Alpine" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_VERSION 3.5.3 12 | ENV POSTGIS_SHA256 44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437 13 | 14 | RUN set -eux \ 15 | && apk add --no-cache --virtual .fetch-deps \ 16 | ca-certificates \ 17 | openssl \ 18 | tar \ 19 | \ 20 | && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ 21 | && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ 22 | && mkdir -p /usr/src/postgis \ 23 | && tar \ 24 | --extract \ 25 | --file postgis.tar.gz \ 26 | --directory /usr/src/postgis \ 27 | --strip-components 1 \ 28 | && rm postgis.tar.gz \ 29 | \ 30 | && apk add --no-cache --virtual .build-deps \ 31 | \ 32 | gdal-dev \ 33 | geos-dev \ 34 | proj-dev \ 35 | proj-util \ 36 | sfcgal-dev \ 37 | \ 38 | # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains 39 | # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. 40 | # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 41 | $DOCKER_PG_LLVM_DEPS \ 42 | \ 43 | autoconf \ 44 | automake \ 45 | cunit-dev \ 46 | file \ 47 | g++ \ 48 | gcc \ 49 | gettext-dev \ 50 | git \ 51 | json-c-dev \ 52 | libtool \ 53 | libxml2-dev \ 54 | make \ 55 | pcre2-dev \ 56 | perl \ 57 | protobuf-c-dev \ 58 | \ 59 | # build PostGIS - with Link Time Optimization (LTO) enabled 60 | && cd /usr/src/postgis \ 61 | && gettextize \ 62 | && ./autogen.sh \ 63 | && ./configure \ 64 | --enable-lto \ 65 | && make -j$(nproc) \ 66 | && make install \ 67 | \ 68 | # This section is for refreshing the proj data for the regression tests. 69 | # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 70 | # This increases the Docker image size by about 1 MB. 71 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 72 | && projsync --system-directory --file us_noaa_eshpgn \ 73 | && projsync --system-directory --file us_noaa_prvi \ 74 | && projsync --system-directory --file us_noaa_wmhpgn \ 75 | # This section performs a regression check. 76 | && mkdir /tempdb \ 77 | && chown -R postgres:postgres /tempdb \ 78 | && su postgres -c 'pg_ctl -D /tempdb init' \ 79 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 80 | && cd regress \ 81 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 82 | \ 83 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 84 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 85 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 86 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 87 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 88 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 89 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 90 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 91 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 92 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 93 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 94 | \ 95 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 96 | && rm -rf /tempdb \ 97 | && rm -rf /tmp/logfile \ 98 | && rm -rf /tmp/pgis_reg \ 99 | # add .postgis-rundeps 100 | && apk add --no-cache --virtual .postgis-rundeps \ 101 | \ 102 | gdal \ 103 | geos \ 104 | proj \ 105 | sfcgal \ 106 | \ 107 | json-c \ 108 | libstdc++ \ 109 | pcre2 \ 110 | protobuf-c \ 111 | \ 112 | # ca-certificates: for accessing remote raster files 113 | # fix https://github.com/postgis/docker-postgis/issues/307 114 | ca-certificates \ 115 | # clean 116 | && cd / \ 117 | && rm -rf /usr/src/postgis \ 118 | && apk del .fetch-deps .build-deps \ 119 | # At the end of the build, we print the collected information 120 | # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. 121 | && cat /_pgis_full_version.txt 122 | 123 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 124 | COPY ./update-postgis.sh /usr/local/bin 125 | -------------------------------------------------------------------------------- /15-3.5/alpine/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /15-3.5/alpine/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /15-3.5/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /15-3.5/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /16-3.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | 5 | FROM postgres:16-bullseye 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.2+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 16 bullseye" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_MAJOR 3 12 | ENV POSTGIS_VERSION 3.5.2+dfsg-1.pgdg110+1 13 | 14 | RUN apt-get update \ 15 | && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ 16 | && apt-get install -y --no-install-recommends \ 17 | # ca-certificates: for accessing remote raster files; 18 | # fix: https://github.com/postgis/docker-postgis/issues/307 19 | ca-certificates \ 20 | \ 21 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ 22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | RUN mkdir -p /docker-entrypoint-initdb.d 26 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 27 | COPY ./update-postgis.sh /usr/local/bin 28 | 29 | -------------------------------------------------------------------------------- /16-3.5/alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | ARG BASE_IMAGE=postgres:16-alpine3.22 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.3 spatial database extension with PostgreSQL 16 Alpine" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_VERSION 3.5.3 12 | ENV POSTGIS_SHA256 44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437 13 | 14 | RUN set -eux \ 15 | && apk add --no-cache --virtual .fetch-deps \ 16 | ca-certificates \ 17 | openssl \ 18 | tar \ 19 | \ 20 | && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ 21 | && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ 22 | && mkdir -p /usr/src/postgis \ 23 | && tar \ 24 | --extract \ 25 | --file postgis.tar.gz \ 26 | --directory /usr/src/postgis \ 27 | --strip-components 1 \ 28 | && rm postgis.tar.gz \ 29 | \ 30 | && apk add --no-cache --virtual .build-deps \ 31 | \ 32 | gdal-dev \ 33 | geos-dev \ 34 | proj-dev \ 35 | proj-util \ 36 | sfcgal-dev \ 37 | \ 38 | # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains 39 | # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. 40 | # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 41 | $DOCKER_PG_LLVM_DEPS \ 42 | \ 43 | autoconf \ 44 | automake \ 45 | cunit-dev \ 46 | file \ 47 | g++ \ 48 | gcc \ 49 | gettext-dev \ 50 | git \ 51 | json-c-dev \ 52 | libtool \ 53 | libxml2-dev \ 54 | make \ 55 | pcre2-dev \ 56 | perl \ 57 | protobuf-c-dev \ 58 | \ 59 | # build PostGIS - with Link Time Optimization (LTO) enabled 60 | && cd /usr/src/postgis \ 61 | && gettextize \ 62 | && ./autogen.sh \ 63 | && ./configure \ 64 | --enable-lto \ 65 | && make -j$(nproc) \ 66 | && make install \ 67 | \ 68 | # This section is for refreshing the proj data for the regression tests. 69 | # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 70 | # This increases the Docker image size by about 1 MB. 71 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 72 | && projsync --system-directory --file us_noaa_eshpgn \ 73 | && projsync --system-directory --file us_noaa_prvi \ 74 | && projsync --system-directory --file us_noaa_wmhpgn \ 75 | # This section performs a regression check. 76 | && mkdir /tempdb \ 77 | && chown -R postgres:postgres /tempdb \ 78 | && su postgres -c 'pg_ctl -D /tempdb init' \ 79 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 80 | && cd regress \ 81 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 82 | \ 83 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 84 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 85 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 86 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 87 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 88 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 89 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 90 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 91 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 92 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 93 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 94 | \ 95 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 96 | && rm -rf /tempdb \ 97 | && rm -rf /tmp/logfile \ 98 | && rm -rf /tmp/pgis_reg \ 99 | # add .postgis-rundeps 100 | && apk add --no-cache --virtual .postgis-rundeps \ 101 | \ 102 | gdal \ 103 | geos \ 104 | proj \ 105 | sfcgal \ 106 | \ 107 | json-c \ 108 | libstdc++ \ 109 | pcre2 \ 110 | protobuf-c \ 111 | \ 112 | # ca-certificates: for accessing remote raster files 113 | # fix https://github.com/postgis/docker-postgis/issues/307 114 | ca-certificates \ 115 | # clean 116 | && cd / \ 117 | && rm -rf /usr/src/postgis \ 118 | && apk del .fetch-deps .build-deps \ 119 | # At the end of the build, we print the collected information 120 | # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. 121 | && cat /_pgis_full_version.txt 122 | 123 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 124 | COPY ./update-postgis.sh /usr/local/bin 125 | -------------------------------------------------------------------------------- /16-3.5/alpine/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /16-3.5/alpine/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /16-3.5/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /16-3.5/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /16-master/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | 5 | # "Experimental"; solely for testing purposes. Anticipate frequent changes! 6 | # This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. 7 | 8 | ARG DOCKER_CMAKE_BUILD_TYPE=Release 9 | ARG CGAL_GIT_BRANCH=master 10 | FROM postgres:16-bullseye as builder 11 | 12 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 13 | org.opencontainers.image.description="PostGIS - master spatial database extension with PostgreSQL 16 bullseye" \ 14 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 15 | 16 | WORKDIR / 17 | 18 | # apt-get install 19 | RUN set -ex \ 20 | && apt-get update \ 21 | && apt-get install -y --no-install-recommends \ 22 | curl \ 23 | libboost-atomic1.74.0 \ 24 | libboost-chrono1.74.0 \ 25 | libboost-date-time1.74.0 \ 26 | libboost-filesystem1.74.0 \ 27 | libboost-program-options1.74.0 \ 28 | libboost-serialization1.74.0 \ 29 | libboost-system1.74.0 \ 30 | libboost-test1.74.0 \ 31 | libboost-thread1.74.0 \ 32 | libboost-timer1.74.0 \ 33 | libcurl3-gnutls \ 34 | libexpat1 \ 35 | libgmp10 \ 36 | libgmpxx4ldbl \ 37 | libjson-c5 \ 38 | libmpfr6 \ 39 | libprotobuf-c1 \ 40 | libtiff5 \ 41 | libxml2 \ 42 | sqlite3 \ 43 | # build dependency 44 | autoconf \ 45 | automake \ 46 | autotools-dev \ 47 | bison \ 48 | build-essential \ 49 | ca-certificates \ 50 | cmake \ 51 | g++ \ 52 | git \ 53 | libboost-all-dev \ 54 | libcurl4-gnutls-dev \ 55 | libgmp-dev \ 56 | libjson-c-dev \ 57 | libmpfr-dev \ 58 | libpcre3-dev \ 59 | libpq-dev \ 60 | libprotobuf-c-dev \ 61 | libsqlite3-dev \ 62 | libtiff-dev \ 63 | libtool \ 64 | libxml2-dev \ 65 | make \ 66 | pkg-config \ 67 | protobuf-c-compiler \ 68 | xsltproc \ 69 | # gdal+ 70 | libblosc-dev \ 71 | libcfitsio-dev \ 72 | libfreexl-dev \ 73 | libfyba-dev \ 74 | libhdf5-dev \ 75 | libkml-dev \ 76 | liblz4-dev \ 77 | liblzma-dev \ 78 | libopenjp2-7-dev \ 79 | libqhull-dev \ 80 | libwebp-dev \ 81 | libzstd-dev 82 | 83 | ARG DOCKER_CMAKE_BUILD_TYPE 84 | ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} 85 | 86 | # cgal & sfcgal 87 | ARG CGAL_GIT_BRANCH 88 | ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} 89 | ENV CGAL_GIT_HASH 616ce1b0d7247e0d23ce03b48d51b0317da4589a 90 | ENV SFCGAL_GIT_HASH 75b69839a8022a33ef12fb6d9259582ece16af7b 91 | RUN set -ex \ 92 | && mkdir -p /usr/src \ 93 | && cd /usr/src \ 94 | && git clone --branch ${CGAL_GIT_BRANCH} https://github.com/CGAL/cgal \ 95 | && cd cgal \ 96 | && git checkout ${CGAL_GIT_HASH} \ 97 | && git log -1 > /_pgis_cgal_last_commit.txt \ 98 | && cd /usr/src \ 99 | && git clone https://gitlab.com/SFCGAL/SFCGAL.git \ 100 | && cd SFCGAL \ 101 | && git checkout ${SFCGAL_GIT_HASH} \ 102 | && git log -1 > /_pgis_sfcgal_last_commit.txt \ 103 | && mkdir cmake-build \ 104 | && cd cmake-build \ 105 | && cmake .. \ 106 | -DCGAL_DIR=/usr/src/cgal \ 107 | -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} \ 108 | -DSFCGAL_BUILD_BENCH=OFF \ 109 | -DSFCGAL_BUILD_EXAMPLES=OFF \ 110 | -DSFCGAL_BUILD_TESTS=OFF \ 111 | -DSFCGAL_WITH_OSG=OFF \ 112 | && make -j$(nproc) \ 113 | && make install \ 114 | # 115 | ## testing with -DSFCGAL_BUILD_TESTS=ON 116 | # && CTEST_OUTPUT_ON_FAILURE=TRUE ctest \ 117 | # 118 | # clean 119 | && rm -fr /usr/src/SFCGAL \ 120 | && rm -fr /usr/src/cgal 121 | 122 | # proj 123 | ENV PROJ_GIT_HASH 8879a1aa695c235497c986759f5deb4402ceb21d 124 | RUN set -ex \ 125 | && cd /usr/src \ 126 | && git clone https://github.com/OSGeo/PROJ.git \ 127 | && cd PROJ \ 128 | && git checkout ${PROJ_GIT_HASH} \ 129 | && git log -1 > /_pgis_proj_last_commit.txt \ 130 | # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 131 | && if [ -f "autogen.sh" ] ; then \ 132 | set -eux \ 133 | && echo "autotools version: 'autogen.sh' exists! Older version!" \ 134 | && ./autogen.sh \ 135 | && ./configure --disable-static \ 136 | && make -j$(nproc) \ 137 | && make install \ 138 | ; \ 139 | else \ 140 | set -eux \ 141 | && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ 142 | && mkdir build \ 143 | && cd build \ 144 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 145 | && make -j$(nproc) \ 146 | && make install \ 147 | ; \ 148 | fi \ 149 | \ 150 | && rm -fr /usr/src/PROJ 151 | 152 | # geos 153 | ENV GEOS_GIT_HASH b577e3056f5a3ecec7bb1ded2181591a87b06149 154 | RUN set -ex \ 155 | && cd /usr/src \ 156 | && git clone https://github.com/libgeos/geos.git \ 157 | && cd geos \ 158 | && git checkout ${GEOS_GIT_HASH} \ 159 | && git log -1 > /_pgis_geos_last_commit.txt \ 160 | && mkdir cmake-build \ 161 | && cd cmake-build \ 162 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 163 | && make -j$(nproc) \ 164 | && make install \ 165 | && cd / \ 166 | && rm -fr /usr/src/geos 167 | 168 | # gdal 169 | ENV GDAL_GIT_HASH 86a6f174cd2f0df1f4ab1aeaf043057caaf19005 170 | RUN set -ex \ 171 | && cd /usr/src \ 172 | && git clone https://github.com/OSGeo/gdal.git \ 173 | && cd gdal \ 174 | && git checkout ${GDAL_GIT_HASH} \ 175 | && git log -1 > /_pgis_gdal_last_commit.txt \ 176 | \ 177 | # gdal project directory structure - has been changed ! 178 | && if [ -d "gdal" ] ; then \ 179 | echo "Directory 'gdal' dir exists -> older version!" ; \ 180 | cd gdal ; \ 181 | else \ 182 | echo "Directory 'gdal' does not exists! Newer version! " ; \ 183 | fi \ 184 | \ 185 | && if [ -f "./autogen.sh" ]; then \ 186 | # Building with autoconf ( old/deprecated ) 187 | set -eux \ 188 | && ./autogen.sh \ 189 | && ./configure --disable-static \ 190 | ; \ 191 | else \ 192 | # Building with cmake 193 | set -eux \ 194 | && mkdir build \ 195 | && cd build \ 196 | # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules 197 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 198 | -DBUILD_DOCS=OFF \ 199 | \ 200 | -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ 201 | -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ 202 | -DGDAL_USE_BLOSC=ON \ 203 | -DGDAL_USE_CFITSIO=ON \ 204 | -DGDAL_USE_CURL=ON \ 205 | -DGDAL_USE_DEFLATE=ON \ 206 | -DGDAL_USE_EXPAT=ON \ 207 | -DGDAL_USE_FREEXL=ON \ 208 | -DGDAL_USE_FYBA=ON \ 209 | -DGDAL_USE_GEOS=ON \ 210 | -DGDAL_USE_HDF5=ON \ 211 | -DGDAL_USE_JSONC=ON \ 212 | -DGDAL_USE_LERC_INTERNAL=ON \ 213 | -DGDAL_USE_LIBKML=ON \ 214 | -DGDAL_USE_LIBLZMA=ON \ 215 | -DGDAL_USE_LZ4=ON \ 216 | -DGDAL_USE_OPENJPEG=ON \ 217 | -DGDAL_USE_POSTGRESQL=ON \ 218 | -DGDAL_USE_QHULL=ON \ 219 | -DGDAL_USE_SQLITE3=ON \ 220 | -DGDAL_USE_TIFF=ON \ 221 | -DGDAL_USE_WEBP=ON \ 222 | -DGDAL_USE_ZSTD=ON \ 223 | \ 224 | # OFF and Not working https://github.com/OSGeo/gdal/issues/7100 225 | # -DRENAME_INTERNAL_GEOTIFF_SYMBOLS=ON \ 226 | -DGDAL_USE_ECW=OFF \ 227 | -DGDAL_USE_GEOTIFF=OFF \ 228 | -DGDAL_USE_HEIF=OFF \ 229 | -DGDAL_USE_SPATIALITE=OFF \ 230 | ; \ 231 | fi \ 232 | \ 233 | && make -j$(nproc) \ 234 | && make install \ 235 | && cd / \ 236 | && rm -fr /usr/src/gdal 237 | 238 | # Minimal command line test. 239 | RUN set -ex \ 240 | && ldconfig \ 241 | && cs2cs \ 242 | && ldd $(which gdalinfo) \ 243 | && gdalinfo --version \ 244 | && geos-config --version \ 245 | && ogr2ogr --version \ 246 | && proj \ 247 | && sfcgal-config --version \ 248 | && pcre-config --version 249 | 250 | # ------------------------------------------- 251 | # STAGE final 252 | # ------------------------------------------- 253 | FROM postgres:16-bullseye 254 | 255 | ARG DOCKER_CMAKE_BUILD_TYPE 256 | ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} 257 | 258 | RUN set -ex \ 259 | && apt-get update \ 260 | && apt-get install -y --no-install-recommends \ 261 | curl \ 262 | libboost-atomic1.74.0 \ 263 | libboost-chrono1.74.0 \ 264 | libboost-date-time1.74.0 \ 265 | libboost-filesystem1.74.0 \ 266 | libboost-program-options1.74.0 \ 267 | libboost-serialization1.74.0 \ 268 | libboost-system1.74.0 \ 269 | libboost-test1.74.0 \ 270 | libboost-thread1.74.0 \ 271 | libboost-timer1.74.0 \ 272 | libcurl3-gnutls \ 273 | libexpat1 \ 274 | libgmp10 \ 275 | libgmpxx4ldbl \ 276 | libjson-c5 \ 277 | libmpfr6 \ 278 | libpcre3 \ 279 | libprotobuf-c1 \ 280 | libtiff5 \ 281 | libxml2 \ 282 | sqlite3 \ 283 | # gdal+ 284 | libblosc1 \ 285 | libcfitsio9 \ 286 | libfreexl1 \ 287 | libfyba0 \ 288 | libhdf5-103-1 \ 289 | libkmlbase1 \ 290 | libkmldom1 \ 291 | libkmlengine1 \ 292 | libopenjp2-7 \ 293 | libqhull-r8.0 \ 294 | && apt-get clean \ 295 | && rm -rf /var/lib/apt/lists/* 296 | 297 | COPY --from=builder /_pgis*.* / 298 | COPY --from=builder /usr/local /usr/local 299 | 300 | ARG CGAL_GIT_BRANCH 301 | ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} 302 | ENV CGAL_GIT_HASH 616ce1b0d7247e0d23ce03b48d51b0317da4589a 303 | ENV SFCGAL_GIT_HASH 75b69839a8022a33ef12fb6d9259582ece16af7b 304 | ENV PROJ_GIT_HASH 8879a1aa695c235497c986759f5deb4402ceb21d 305 | ENV GEOS_GIT_HASH b577e3056f5a3ecec7bb1ded2181591a87b06149 306 | ENV GDAL_GIT_HASH 86a6f174cd2f0df1f4ab1aeaf043057caaf19005 307 | 308 | # Minimal command line test ( fail fast ) 309 | RUN set -ex \ 310 | && ldconfig \ 311 | && cs2cs \ 312 | && ldd $(which gdalinfo) \ 313 | && gdalinfo --version \ 314 | && gdal-config --formats \ 315 | && geos-config --version \ 316 | && ogr2ogr --version \ 317 | && proj \ 318 | && sfcgal-config --version \ 319 | \ 320 | # Testing ogr2ogr PostgreSQL driver. 321 | && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ 322 | || echo "ogr2ogr missing PostgreSQL driver" && exit 1 323 | 324 | # install postgis 325 | ENV POSTGIS_GIT_HASH 2b6933ed2dada900b47458421113c2ff60240311 326 | 327 | RUN set -ex \ 328 | && apt-get update \ 329 | && apt-get install -y --no-install-recommends \ 330 | autoconf \ 331 | automake \ 332 | autotools-dev \ 333 | bison \ 334 | build-essential \ 335 | ca-certificates \ 336 | cmake \ 337 | docbook-xml \ 338 | docbook5-xml \ 339 | g++ \ 340 | git \ 341 | libboost-all-dev \ 342 | libcunit1-dev \ 343 | libcurl4-gnutls-dev \ 344 | libgmp-dev \ 345 | libjson-c-dev \ 346 | libmpfr-dev \ 347 | libpcre3-dev \ 348 | libprotobuf-c-dev \ 349 | libsqlite3-dev \ 350 | libtiff-dev \ 351 | libtool \ 352 | libxml2-dev \ 353 | libxml2-utils \ 354 | make \ 355 | pkg-config \ 356 | postgresql-server-dev-$PG_MAJOR \ 357 | protobuf-c-compiler \ 358 | xsltproc \ 359 | && cd \ 360 | # postgis 361 | && cd /usr/src/ \ 362 | && git clone https://github.com/postgis/postgis.git \ 363 | && cd postgis \ 364 | && git checkout ${POSTGIS_GIT_HASH} \ 365 | && git log -1 > /_pgis_last_commit.txt \ 366 | && ./autogen.sh \ 367 | # configure options taken from: 368 | # https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie 369 | && ./configure \ 370 | --enable-lto \ 371 | && make -j$(nproc) \ 372 | && make install \ 373 | # refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 374 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 375 | && projsync --system-directory --file us_noaa_eshpgn \ 376 | && projsync --system-directory --file us_noaa_prvi \ 377 | && projsync --system-directory --file us_noaa_wmhpgn \ 378 | # regress check 379 | && mkdir /tempdb \ 380 | && chown -R postgres:postgres /tempdb \ 381 | && su postgres -c 'pg_ctl -D /tempdb init' \ 382 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 383 | && ldconfig \ 384 | && cd regress \ 385 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 386 | \ 387 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 388 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 389 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 390 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 391 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 392 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 393 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 394 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 395 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 396 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 397 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 398 | \ 399 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 400 | && rm -rf /tempdb \ 401 | && rm -rf /tmp/logfile \ 402 | && rm -rf /tmp/pgis_reg \ 403 | # clean 404 | && cd / \ 405 | && rm -rf /usr/src/postgis \ 406 | && apt-get purge -y --autoremove \ 407 | autoconf \ 408 | automake \ 409 | autotools-dev \ 410 | bison \ 411 | build-essential \ 412 | cmake \ 413 | docbook-xml \ 414 | docbook5-xml \ 415 | g++ \ 416 | git \ 417 | libboost-all-dev \ 418 | libcurl4-gnutls-dev \ 419 | libgmp-dev \ 420 | libjson-c-dev \ 421 | libmpfr-dev \ 422 | libpcre3-dev \ 423 | libprotobuf-c-dev \ 424 | libsqlite3-dev \ 425 | libtiff-dev \ 426 | libtool \ 427 | libxml2-dev \ 428 | libxml2-utils \ 429 | make \ 430 | pkg-config \ 431 | postgresql-server-dev-$PG_MAJOR \ 432 | protobuf-c-compiler \ 433 | xsltproc \ 434 | && apt-get clean \ 435 | && rm -rf /var/lib/apt/lists/* 436 | 437 | RUN mkdir -p /docker-entrypoint-initdb.d 438 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 439 | COPY ./update-postgis.sh /usr/local/bin 440 | 441 | # last final test 442 | RUN set -ex \ 443 | && ldconfig \ 444 | && cs2cs \ 445 | && ldd $(which gdalinfo) \ 446 | && gdalinfo --version \ 447 | && gdal-config --formats \ 448 | && geos-config --version \ 449 | && ogr2ogr --version \ 450 | && proj \ 451 | && sfcgal-config --version \ 452 | \ 453 | # Is the "ca-certificates" package installed? (for accessing remote raster files) 454 | # https://github.com/postgis/docker-postgis/issues/307 455 | && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ 456 | \ 457 | # list last commits. 458 | && find /_pgis_*_last_commit.txt -type f -print -exec cat {} \; \ 459 | # list postgresql, postgis version 460 | && cat _pgis_full_version.txt 461 | -------------------------------------------------------------------------------- /16-master/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /16-master/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /17-3.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | 5 | FROM postgres:17-bullseye 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.2+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 17 bullseye" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_MAJOR 3 12 | ENV POSTGIS_VERSION 3.5.2+dfsg-1.pgdg110+1 13 | 14 | RUN apt-get update \ 15 | && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ 16 | && apt-get install -y --no-install-recommends \ 17 | # ca-certificates: for accessing remote raster files; 18 | # fix: https://github.com/postgis/docker-postgis/issues/307 19 | ca-certificates \ 20 | \ 21 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ 22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | RUN mkdir -p /docker-entrypoint-initdb.d 26 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 27 | COPY ./update-postgis.sh /usr/local/bin 28 | 29 | -------------------------------------------------------------------------------- /17-3.5/alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | ARG BASE_IMAGE=postgres:17-alpine3.22 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.5.3 spatial database extension with PostgreSQL 17 Alpine" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_VERSION 3.5.3 12 | ENV POSTGIS_SHA256 44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437 13 | 14 | RUN set -eux \ 15 | && apk add --no-cache --virtual .fetch-deps \ 16 | ca-certificates \ 17 | openssl \ 18 | tar \ 19 | \ 20 | && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ 21 | && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ 22 | && mkdir -p /usr/src/postgis \ 23 | && tar \ 24 | --extract \ 25 | --file postgis.tar.gz \ 26 | --directory /usr/src/postgis \ 27 | --strip-components 1 \ 28 | && rm postgis.tar.gz \ 29 | \ 30 | && apk add --no-cache --virtual .build-deps \ 31 | \ 32 | gdal-dev \ 33 | geos-dev \ 34 | proj-dev \ 35 | proj-util \ 36 | sfcgal-dev \ 37 | \ 38 | # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains 39 | # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. 40 | # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 41 | $DOCKER_PG_LLVM_DEPS \ 42 | \ 43 | autoconf \ 44 | automake \ 45 | cunit-dev \ 46 | file \ 47 | g++ \ 48 | gcc \ 49 | gettext-dev \ 50 | git \ 51 | json-c-dev \ 52 | libtool \ 53 | libxml2-dev \ 54 | make \ 55 | pcre2-dev \ 56 | perl \ 57 | protobuf-c-dev \ 58 | \ 59 | # build PostGIS - with Link Time Optimization (LTO) enabled 60 | && cd /usr/src/postgis \ 61 | && gettextize \ 62 | && ./autogen.sh \ 63 | && ./configure \ 64 | --enable-lto \ 65 | && make -j$(nproc) \ 66 | && make install \ 67 | \ 68 | # This section is for refreshing the proj data for the regression tests. 69 | # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 70 | # This increases the Docker image size by about 1 MB. 71 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 72 | && projsync --system-directory --file us_noaa_eshpgn \ 73 | && projsync --system-directory --file us_noaa_prvi \ 74 | && projsync --system-directory --file us_noaa_wmhpgn \ 75 | # This section performs a regression check. 76 | && mkdir /tempdb \ 77 | && chown -R postgres:postgres /tempdb \ 78 | && su postgres -c 'pg_ctl -D /tempdb init' \ 79 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 80 | && cd regress \ 81 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 82 | \ 83 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 84 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 85 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 86 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 87 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 88 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 89 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 90 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 91 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 92 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 93 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 94 | \ 95 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 96 | && rm -rf /tempdb \ 97 | && rm -rf /tmp/logfile \ 98 | && rm -rf /tmp/pgis_reg \ 99 | # add .postgis-rundeps 100 | && apk add --no-cache --virtual .postgis-rundeps \ 101 | \ 102 | gdal \ 103 | geos \ 104 | proj \ 105 | sfcgal \ 106 | \ 107 | json-c \ 108 | libstdc++ \ 109 | pcre2 \ 110 | protobuf-c \ 111 | \ 112 | # ca-certificates: for accessing remote raster files 113 | # fix https://github.com/postgis/docker-postgis/issues/307 114 | ca-certificates \ 115 | # clean 116 | && cd / \ 117 | && rm -rf /usr/src/postgis \ 118 | && apk del .fetch-deps .build-deps \ 119 | # At the end of the build, we print the collected information 120 | # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. 121 | && cat /_pgis_full_version.txt 122 | 123 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 124 | COPY ./update-postgis.sh /usr/local/bin 125 | -------------------------------------------------------------------------------- /17-3.5/alpine/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /17-3.5/alpine/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /17-3.5/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /17-3.5/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /17-3.6.0alpha1/Dockerfile: -------------------------------------------------------------------------------- 1 | # placeholder Dockerfile 2 | # Debian version of postgis is not detected! 3 | # This is an autogenerated message of ./update.sh 4 | -------------------------------------------------------------------------------- /17-3.6.0alpha1/alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | ARG BASE_IMAGE=postgres:17-alpine3.22 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS 3.6.0alpha1 spatial database extension with PostgreSQL 17 Alpine" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_VERSION 3.6.0alpha1 12 | ENV POSTGIS_SHA256 9f1981716001afff2e4ec75e4107cb64e8d3d9d26ad2abf573444038db0830eb 13 | 14 | RUN set -eux \ 15 | && apk add --no-cache --virtual .fetch-deps \ 16 | ca-certificates \ 17 | openssl \ 18 | tar \ 19 | \ 20 | && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ 21 | && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ 22 | && mkdir -p /usr/src/postgis \ 23 | && tar \ 24 | --extract \ 25 | --file postgis.tar.gz \ 26 | --directory /usr/src/postgis \ 27 | --strip-components 1 \ 28 | && rm postgis.tar.gz \ 29 | \ 30 | && apk add --no-cache --virtual .build-deps \ 31 | \ 32 | gdal-dev \ 33 | geos-dev \ 34 | proj-dev \ 35 | proj-util \ 36 | sfcgal-dev \ 37 | \ 38 | # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains 39 | # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. 40 | # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 41 | $DOCKER_PG_LLVM_DEPS \ 42 | \ 43 | autoconf \ 44 | automake \ 45 | cunit-dev \ 46 | file \ 47 | g++ \ 48 | gcc \ 49 | gettext-dev \ 50 | git \ 51 | json-c-dev \ 52 | libtool \ 53 | libxml2-dev \ 54 | make \ 55 | pcre2-dev \ 56 | perl \ 57 | protobuf-c-dev \ 58 | \ 59 | # build PostGIS - with Link Time Optimization (LTO) enabled 60 | && cd /usr/src/postgis \ 61 | && gettextize \ 62 | && ./autogen.sh \ 63 | && ./configure \ 64 | --enable-lto \ 65 | && make -j$(nproc) \ 66 | && make install \ 67 | \ 68 | # This section is for refreshing the proj data for the regression tests. 69 | # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 70 | # This increases the Docker image size by about 1 MB. 71 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 72 | && projsync --system-directory --file us_noaa_eshpgn \ 73 | && projsync --system-directory --file us_noaa_prvi \ 74 | && projsync --system-directory --file us_noaa_wmhpgn \ 75 | # This section performs a regression check. 76 | && mkdir /tempdb \ 77 | && chown -R postgres:postgres /tempdb \ 78 | && su postgres -c 'pg_ctl -D /tempdb init' \ 79 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 80 | && cd regress \ 81 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 82 | \ 83 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 84 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 85 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 86 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 87 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 88 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 89 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 90 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 91 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 92 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 93 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 94 | \ 95 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 96 | && rm -rf /tempdb \ 97 | && rm -rf /tmp/logfile \ 98 | && rm -rf /tmp/pgis_reg \ 99 | # add .postgis-rundeps 100 | && apk add --no-cache --virtual .postgis-rundeps \ 101 | \ 102 | gdal \ 103 | geos \ 104 | proj \ 105 | sfcgal \ 106 | \ 107 | json-c \ 108 | libstdc++ \ 109 | pcre2 \ 110 | protobuf-c \ 111 | \ 112 | # ca-certificates: for accessing remote raster files 113 | # fix https://github.com/postgis/docker-postgis/issues/307 114 | ca-certificates \ 115 | # clean 116 | && cd / \ 117 | && rm -rf /usr/src/postgis \ 118 | && apk del .fetch-deps .build-deps \ 119 | # At the end of the build, we print the collected information 120 | # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. 121 | && cat /_pgis_full_version.txt 122 | 123 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 124 | COPY ./update-postgis.sh /usr/local/bin 125 | -------------------------------------------------------------------------------- /17-3.6.0alpha1/alpine/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /17-3.6.0alpha1/alpine/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /17-master/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. 3 | # 4 | 5 | # "Experimental"; solely for testing purposes. Anticipate frequent changes! 6 | # This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. 7 | 8 | ARG DOCKER_CMAKE_BUILD_TYPE=Release 9 | ARG CGAL_GIT_BRANCH=master 10 | FROM postgres:17-bullseye as builder 11 | 12 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 13 | org.opencontainers.image.description="PostGIS - master spatial database extension with PostgreSQL 17 bullseye" \ 14 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 15 | 16 | WORKDIR / 17 | 18 | # apt-get install 19 | RUN set -ex \ 20 | && apt-get update \ 21 | && apt-get install -y --no-install-recommends \ 22 | curl \ 23 | libboost-atomic1.74.0 \ 24 | libboost-chrono1.74.0 \ 25 | libboost-date-time1.74.0 \ 26 | libboost-filesystem1.74.0 \ 27 | libboost-program-options1.74.0 \ 28 | libboost-serialization1.74.0 \ 29 | libboost-system1.74.0 \ 30 | libboost-test1.74.0 \ 31 | libboost-thread1.74.0 \ 32 | libboost-timer1.74.0 \ 33 | libcurl3-gnutls \ 34 | libexpat1 \ 35 | libgmp10 \ 36 | libgmpxx4ldbl \ 37 | libjson-c5 \ 38 | libmpfr6 \ 39 | libprotobuf-c1 \ 40 | libtiff5 \ 41 | libxml2 \ 42 | sqlite3 \ 43 | # build dependency 44 | autoconf \ 45 | automake \ 46 | autotools-dev \ 47 | bison \ 48 | build-essential \ 49 | ca-certificates \ 50 | cmake \ 51 | g++ \ 52 | git \ 53 | libboost-all-dev \ 54 | libcurl4-gnutls-dev \ 55 | libgmp-dev \ 56 | libjson-c-dev \ 57 | libmpfr-dev \ 58 | libpcre3-dev \ 59 | libpq-dev \ 60 | libprotobuf-c-dev \ 61 | libsqlite3-dev \ 62 | libtiff-dev \ 63 | libtool \ 64 | libxml2-dev \ 65 | make \ 66 | pkg-config \ 67 | protobuf-c-compiler \ 68 | xsltproc \ 69 | # gdal+ 70 | libblosc-dev \ 71 | libcfitsio-dev \ 72 | libfreexl-dev \ 73 | libfyba-dev \ 74 | libhdf5-dev \ 75 | libkml-dev \ 76 | liblz4-dev \ 77 | liblzma-dev \ 78 | libopenjp2-7-dev \ 79 | libqhull-dev \ 80 | libwebp-dev \ 81 | libzstd-dev 82 | 83 | ARG DOCKER_CMAKE_BUILD_TYPE 84 | ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} 85 | 86 | # cgal & sfcgal 87 | ARG CGAL_GIT_BRANCH 88 | ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} 89 | ENV CGAL_GIT_HASH 616ce1b0d7247e0d23ce03b48d51b0317da4589a 90 | ENV SFCGAL_GIT_HASH 75b69839a8022a33ef12fb6d9259582ece16af7b 91 | RUN set -ex \ 92 | && mkdir -p /usr/src \ 93 | && cd /usr/src \ 94 | && git clone --branch ${CGAL_GIT_BRANCH} https://github.com/CGAL/cgal \ 95 | && cd cgal \ 96 | && git checkout ${CGAL_GIT_HASH} \ 97 | && git log -1 > /_pgis_cgal_last_commit.txt \ 98 | && cd /usr/src \ 99 | && git clone https://gitlab.com/SFCGAL/SFCGAL.git \ 100 | && cd SFCGAL \ 101 | && git checkout ${SFCGAL_GIT_HASH} \ 102 | && git log -1 > /_pgis_sfcgal_last_commit.txt \ 103 | && mkdir cmake-build \ 104 | && cd cmake-build \ 105 | && cmake .. \ 106 | -DCGAL_DIR=/usr/src/cgal \ 107 | -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} \ 108 | -DSFCGAL_BUILD_BENCH=OFF \ 109 | -DSFCGAL_BUILD_EXAMPLES=OFF \ 110 | -DSFCGAL_BUILD_TESTS=OFF \ 111 | -DSFCGAL_WITH_OSG=OFF \ 112 | && make -j$(nproc) \ 113 | && make install \ 114 | # 115 | ## testing with -DSFCGAL_BUILD_TESTS=ON 116 | # && CTEST_OUTPUT_ON_FAILURE=TRUE ctest \ 117 | # 118 | # clean 119 | && rm -fr /usr/src/SFCGAL \ 120 | && rm -fr /usr/src/cgal 121 | 122 | # proj 123 | ENV PROJ_GIT_HASH 8879a1aa695c235497c986759f5deb4402ceb21d 124 | RUN set -ex \ 125 | && cd /usr/src \ 126 | && git clone https://github.com/OSGeo/PROJ.git \ 127 | && cd PROJ \ 128 | && git checkout ${PROJ_GIT_HASH} \ 129 | && git log -1 > /_pgis_proj_last_commit.txt \ 130 | # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 131 | && if [ -f "autogen.sh" ] ; then \ 132 | set -eux \ 133 | && echo "autotools version: 'autogen.sh' exists! Older version!" \ 134 | && ./autogen.sh \ 135 | && ./configure --disable-static \ 136 | && make -j$(nproc) \ 137 | && make install \ 138 | ; \ 139 | else \ 140 | set -eux \ 141 | && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ 142 | && mkdir build \ 143 | && cd build \ 144 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 145 | && make -j$(nproc) \ 146 | && make install \ 147 | ; \ 148 | fi \ 149 | \ 150 | && rm -fr /usr/src/PROJ 151 | 152 | # geos 153 | ENV GEOS_GIT_HASH b577e3056f5a3ecec7bb1ded2181591a87b06149 154 | RUN set -ex \ 155 | && cd /usr/src \ 156 | && git clone https://github.com/libgeos/geos.git \ 157 | && cd geos \ 158 | && git checkout ${GEOS_GIT_HASH} \ 159 | && git log -1 > /_pgis_geos_last_commit.txt \ 160 | && mkdir cmake-build \ 161 | && cd cmake-build \ 162 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 163 | && make -j$(nproc) \ 164 | && make install \ 165 | && cd / \ 166 | && rm -fr /usr/src/geos 167 | 168 | # gdal 169 | ENV GDAL_GIT_HASH 86a6f174cd2f0df1f4ab1aeaf043057caaf19005 170 | RUN set -ex \ 171 | && cd /usr/src \ 172 | && git clone https://github.com/OSGeo/gdal.git \ 173 | && cd gdal \ 174 | && git checkout ${GDAL_GIT_HASH} \ 175 | && git log -1 > /_pgis_gdal_last_commit.txt \ 176 | \ 177 | # gdal project directory structure - has been changed ! 178 | && if [ -d "gdal" ] ; then \ 179 | echo "Directory 'gdal' dir exists -> older version!" ; \ 180 | cd gdal ; \ 181 | else \ 182 | echo "Directory 'gdal' does not exists! Newer version! " ; \ 183 | fi \ 184 | \ 185 | && if [ -f "./autogen.sh" ]; then \ 186 | # Building with autoconf ( old/deprecated ) 187 | set -eux \ 188 | && ./autogen.sh \ 189 | && ./configure --disable-static \ 190 | ; \ 191 | else \ 192 | # Building with cmake 193 | set -eux \ 194 | && mkdir build \ 195 | && cd build \ 196 | # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules 197 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 198 | -DBUILD_DOCS=OFF \ 199 | \ 200 | -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ 201 | -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ 202 | -DGDAL_USE_BLOSC=ON \ 203 | -DGDAL_USE_CFITSIO=ON \ 204 | -DGDAL_USE_CURL=ON \ 205 | -DGDAL_USE_DEFLATE=ON \ 206 | -DGDAL_USE_EXPAT=ON \ 207 | -DGDAL_USE_FREEXL=ON \ 208 | -DGDAL_USE_FYBA=ON \ 209 | -DGDAL_USE_GEOS=ON \ 210 | -DGDAL_USE_HDF5=ON \ 211 | -DGDAL_USE_JSONC=ON \ 212 | -DGDAL_USE_LERC_INTERNAL=ON \ 213 | -DGDAL_USE_LIBKML=ON \ 214 | -DGDAL_USE_LIBLZMA=ON \ 215 | -DGDAL_USE_LZ4=ON \ 216 | -DGDAL_USE_OPENJPEG=ON \ 217 | -DGDAL_USE_POSTGRESQL=ON \ 218 | -DGDAL_USE_QHULL=ON \ 219 | -DGDAL_USE_SQLITE3=ON \ 220 | -DGDAL_USE_TIFF=ON \ 221 | -DGDAL_USE_WEBP=ON \ 222 | -DGDAL_USE_ZSTD=ON \ 223 | \ 224 | # OFF and Not working https://github.com/OSGeo/gdal/issues/7100 225 | # -DRENAME_INTERNAL_GEOTIFF_SYMBOLS=ON \ 226 | -DGDAL_USE_ECW=OFF \ 227 | -DGDAL_USE_GEOTIFF=OFF \ 228 | -DGDAL_USE_HEIF=OFF \ 229 | -DGDAL_USE_SPATIALITE=OFF \ 230 | ; \ 231 | fi \ 232 | \ 233 | && make -j$(nproc) \ 234 | && make install \ 235 | && cd / \ 236 | && rm -fr /usr/src/gdal 237 | 238 | # Minimal command line test. 239 | RUN set -ex \ 240 | && ldconfig \ 241 | && cs2cs \ 242 | && ldd $(which gdalinfo) \ 243 | && gdalinfo --version \ 244 | && geos-config --version \ 245 | && ogr2ogr --version \ 246 | && proj \ 247 | && sfcgal-config --version \ 248 | && pcre-config --version 249 | 250 | # ------------------------------------------- 251 | # STAGE final 252 | # ------------------------------------------- 253 | FROM postgres:17-bullseye 254 | 255 | ARG DOCKER_CMAKE_BUILD_TYPE 256 | ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} 257 | 258 | RUN set -ex \ 259 | && apt-get update \ 260 | && apt-get install -y --no-install-recommends \ 261 | curl \ 262 | libboost-atomic1.74.0 \ 263 | libboost-chrono1.74.0 \ 264 | libboost-date-time1.74.0 \ 265 | libboost-filesystem1.74.0 \ 266 | libboost-program-options1.74.0 \ 267 | libboost-serialization1.74.0 \ 268 | libboost-system1.74.0 \ 269 | libboost-test1.74.0 \ 270 | libboost-thread1.74.0 \ 271 | libboost-timer1.74.0 \ 272 | libcurl3-gnutls \ 273 | libexpat1 \ 274 | libgmp10 \ 275 | libgmpxx4ldbl \ 276 | libjson-c5 \ 277 | libmpfr6 \ 278 | libpcre3 \ 279 | libprotobuf-c1 \ 280 | libtiff5 \ 281 | libxml2 \ 282 | sqlite3 \ 283 | # gdal+ 284 | libblosc1 \ 285 | libcfitsio9 \ 286 | libfreexl1 \ 287 | libfyba0 \ 288 | libhdf5-103-1 \ 289 | libkmlbase1 \ 290 | libkmldom1 \ 291 | libkmlengine1 \ 292 | libopenjp2-7 \ 293 | libqhull-r8.0 \ 294 | && apt-get clean \ 295 | && rm -rf /var/lib/apt/lists/* 296 | 297 | COPY --from=builder /_pgis*.* / 298 | COPY --from=builder /usr/local /usr/local 299 | 300 | ARG CGAL_GIT_BRANCH 301 | ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} 302 | ENV CGAL_GIT_HASH 616ce1b0d7247e0d23ce03b48d51b0317da4589a 303 | ENV SFCGAL_GIT_HASH 75b69839a8022a33ef12fb6d9259582ece16af7b 304 | ENV PROJ_GIT_HASH 8879a1aa695c235497c986759f5deb4402ceb21d 305 | ENV GEOS_GIT_HASH b577e3056f5a3ecec7bb1ded2181591a87b06149 306 | ENV GDAL_GIT_HASH 86a6f174cd2f0df1f4ab1aeaf043057caaf19005 307 | 308 | # Minimal command line test ( fail fast ) 309 | RUN set -ex \ 310 | && ldconfig \ 311 | && cs2cs \ 312 | && ldd $(which gdalinfo) \ 313 | && gdalinfo --version \ 314 | && gdal-config --formats \ 315 | && geos-config --version \ 316 | && ogr2ogr --version \ 317 | && proj \ 318 | && sfcgal-config --version \ 319 | \ 320 | # Testing ogr2ogr PostgreSQL driver. 321 | && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ 322 | || echo "ogr2ogr missing PostgreSQL driver" && exit 1 323 | 324 | # install postgis 325 | ENV POSTGIS_GIT_HASH 2b6933ed2dada900b47458421113c2ff60240311 326 | 327 | RUN set -ex \ 328 | && apt-get update \ 329 | && apt-get install -y --no-install-recommends \ 330 | autoconf \ 331 | automake \ 332 | autotools-dev \ 333 | bison \ 334 | build-essential \ 335 | ca-certificates \ 336 | cmake \ 337 | docbook-xml \ 338 | docbook5-xml \ 339 | g++ \ 340 | git \ 341 | libboost-all-dev \ 342 | libcunit1-dev \ 343 | libcurl4-gnutls-dev \ 344 | libgmp-dev \ 345 | libjson-c-dev \ 346 | libmpfr-dev \ 347 | libpcre3-dev \ 348 | libprotobuf-c-dev \ 349 | libsqlite3-dev \ 350 | libtiff-dev \ 351 | libtool \ 352 | libxml2-dev \ 353 | libxml2-utils \ 354 | make \ 355 | pkg-config \ 356 | postgresql-server-dev-$PG_MAJOR \ 357 | protobuf-c-compiler \ 358 | xsltproc \ 359 | && cd \ 360 | # postgis 361 | && cd /usr/src/ \ 362 | && git clone https://github.com/postgis/postgis.git \ 363 | && cd postgis \ 364 | && git checkout ${POSTGIS_GIT_HASH} \ 365 | && git log -1 > /_pgis_last_commit.txt \ 366 | && ./autogen.sh \ 367 | # configure options taken from: 368 | # https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie 369 | && ./configure \ 370 | --enable-lto \ 371 | && make -j$(nproc) \ 372 | && make install \ 373 | # refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 374 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 375 | && projsync --system-directory --file us_noaa_eshpgn \ 376 | && projsync --system-directory --file us_noaa_prvi \ 377 | && projsync --system-directory --file us_noaa_wmhpgn \ 378 | # regress check 379 | && mkdir /tempdb \ 380 | && chown -R postgres:postgres /tempdb \ 381 | && su postgres -c 'pg_ctl -D /tempdb init' \ 382 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 383 | && ldconfig \ 384 | && cd regress \ 385 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 386 | \ 387 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 388 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 389 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 390 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 391 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 392 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 393 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 394 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 395 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 396 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 397 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 398 | \ 399 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 400 | && rm -rf /tempdb \ 401 | && rm -rf /tmp/logfile \ 402 | && rm -rf /tmp/pgis_reg \ 403 | # clean 404 | && cd / \ 405 | && rm -rf /usr/src/postgis \ 406 | && apt-get purge -y --autoremove \ 407 | autoconf \ 408 | automake \ 409 | autotools-dev \ 410 | bison \ 411 | build-essential \ 412 | cmake \ 413 | docbook-xml \ 414 | docbook5-xml \ 415 | g++ \ 416 | git \ 417 | libboost-all-dev \ 418 | libcurl4-gnutls-dev \ 419 | libgmp-dev \ 420 | libjson-c-dev \ 421 | libmpfr-dev \ 422 | libpcre3-dev \ 423 | libprotobuf-c-dev \ 424 | libsqlite3-dev \ 425 | libtiff-dev \ 426 | libtool \ 427 | libxml2-dev \ 428 | libxml2-utils \ 429 | make \ 430 | pkg-config \ 431 | postgresql-server-dev-$PG_MAJOR \ 432 | protobuf-c-compiler \ 433 | xsltproc \ 434 | && apt-get clean \ 435 | && rm -rf /var/lib/apt/lists/* 436 | 437 | RUN mkdir -p /docker-entrypoint-initdb.d 438 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 439 | COPY ./update-postgis.sh /usr/local/bin 440 | 441 | # last final test 442 | RUN set -ex \ 443 | && ldconfig \ 444 | && cs2cs \ 445 | && ldd $(which gdalinfo) \ 446 | && gdalinfo --version \ 447 | && gdal-config --formats \ 448 | && geos-config --version \ 449 | && ogr2ogr --version \ 450 | && proj \ 451 | && sfcgal-config --version \ 452 | \ 453 | # Is the "ca-certificates" package installed? (for accessing remote raster files) 454 | # https://github.com/postgis/docker-postgis/issues/307 455 | && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ 456 | \ 457 | # list last commits. 458 | && find /_pgis_*_last_commit.txt -type f -print -exec cat {} \; \ 459 | # list postgresql, postgis version 460 | && cat _pgis_full_version.txt 461 | -------------------------------------------------------------------------------- /17-master/initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /17-master/update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Mike Dillon 2 | 3 | And other contributors not specifically named here. 4 | -------------------------------------------------------------------------------- /Dockerfile.alpine.template: -------------------------------------------------------------------------------- 1 | # 2 | # %%TXT_AUTOGENERATED%% 3 | # 4 | ARG BASE_IMAGE=postgres:%%PG_MAJOR%%-alpine3.22 5 | FROM ${BASE_IMAGE} 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS %%POSTGIS_VERSION%% spatial database extension with PostgreSQL %%PG_MAJOR%% Alpine" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_VERSION %%POSTGIS_VERSION%% 12 | ENV POSTGIS_SHA256 %%POSTGIS_SHA256%% 13 | 14 | RUN set -eux \ 15 | && apk add --no-cache --virtual .fetch-deps \ 16 | ca-certificates \ 17 | openssl \ 18 | tar \ 19 | \ 20 | && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ 21 | && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ 22 | && mkdir -p /usr/src/postgis \ 23 | && tar \ 24 | --extract \ 25 | --file postgis.tar.gz \ 26 | --directory /usr/src/postgis \ 27 | --strip-components 1 \ 28 | && rm postgis.tar.gz \ 29 | \ 30 | && apk add --no-cache --virtual .build-deps \ 31 | \ 32 | gdal-dev \ 33 | geos-dev \ 34 | proj-dev \ 35 | proj-util \ 36 | sfcgal-dev \ 37 | \ 38 | # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains 39 | # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. 40 | # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 41 | $DOCKER_PG_LLVM_DEPS \ 42 | \ 43 | autoconf \ 44 | automake \ 45 | cunit-dev \ 46 | file \ 47 | g++ \ 48 | gcc \ 49 | gettext-dev \ 50 | git \ 51 | json-c-dev \ 52 | libtool \ 53 | libxml2-dev \ 54 | make \ 55 | pcre2-dev \ 56 | perl \ 57 | protobuf-c-dev \ 58 | \ 59 | # build PostGIS - with Link Time Optimization (LTO) enabled 60 | && cd /usr/src/postgis \ 61 | && gettextize \ 62 | && ./autogen.sh \ 63 | && ./configure \ 64 | --enable-lto \ 65 | && make -j$(nproc) \ 66 | && make install \ 67 | \ 68 | # This section is for refreshing the proj data for the regression tests. 69 | # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 70 | # This increases the Docker image size by about 1 MB. 71 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 72 | && projsync --system-directory --file us_noaa_eshpgn \ 73 | && projsync --system-directory --file us_noaa_prvi \ 74 | && projsync --system-directory --file us_noaa_wmhpgn \ 75 | # This section performs a regression check. 76 | && mkdir /tempdb \ 77 | && chown -R postgres:postgres /tempdb \ 78 | && su postgres -c 'pg_ctl -D /tempdb init' \ 79 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 80 | && cd regress \ 81 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 82 | \ 83 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 84 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 85 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 86 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 87 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 88 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 89 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 90 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 91 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 92 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 93 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 94 | \ 95 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 96 | && rm -rf /tempdb \ 97 | && rm -rf /tmp/logfile \ 98 | && rm -rf /tmp/pgis_reg \ 99 | # add .postgis-rundeps 100 | && apk add --no-cache --virtual .postgis-rundeps \ 101 | \ 102 | gdal \ 103 | geos \ 104 | proj \ 105 | sfcgal \ 106 | \ 107 | json-c \ 108 | libstdc++ \ 109 | pcre2 \ 110 | protobuf-c \ 111 | \ 112 | # ca-certificates: for accessing remote raster files 113 | # fix https://github.com/postgis/docker-postgis/issues/307 114 | ca-certificates \ 115 | # clean 116 | && cd / \ 117 | && rm -rf /usr/src/postgis \ 118 | && apk del .fetch-deps .build-deps \ 119 | # At the end of the build, we print the collected information 120 | # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. 121 | && cat /_pgis_full_version.txt 122 | 123 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 124 | COPY ./update-postgis.sh /usr/local/bin 125 | -------------------------------------------------------------------------------- /Dockerfile.master.template: -------------------------------------------------------------------------------- 1 | # 2 | # %%TXT_AUTOGENERATED%% 3 | # 4 | 5 | # "Experimental"; solely for testing purposes. Anticipate frequent changes! 6 | # This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. 7 | 8 | ARG DOCKER_CMAKE_BUILD_TYPE=Release 9 | ARG CGAL_GIT_BRANCH=master 10 | FROM postgres:%%PG_MAJOR%%-%%DEBIAN_VERSION%% as builder 11 | 12 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 13 | org.opencontainers.image.description="PostGIS - master spatial database extension with PostgreSQL %%PG_MAJOR%% %%DEBIAN_VERSION%%" \ 14 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 15 | 16 | WORKDIR / 17 | 18 | # apt-get install 19 | RUN set -ex \ 20 | && apt-get update \ 21 | && apt-get install -y --no-install-recommends \ 22 | curl \ 23 | libboost-atomic%%BOOST_VERSION%% \ 24 | libboost-chrono%%BOOST_VERSION%% \ 25 | libboost-date-time%%BOOST_VERSION%% \ 26 | libboost-filesystem%%BOOST_VERSION%% \ 27 | libboost-program-options%%BOOST_VERSION%% \ 28 | libboost-serialization%%BOOST_VERSION%% \ 29 | libboost-system%%BOOST_VERSION%% \ 30 | libboost-test%%BOOST_VERSION%% \ 31 | libboost-thread%%BOOST_VERSION%% \ 32 | libboost-timer%%BOOST_VERSION%% \ 33 | libcurl3-gnutls \ 34 | libexpat1 \ 35 | libgmp10 \ 36 | libgmpxx4ldbl \ 37 | libjson-c5 \ 38 | libmpfr6 \ 39 | libprotobuf-c1 \ 40 | libtiff5 \ 41 | libxml2 \ 42 | sqlite3 \ 43 | # build dependency 44 | autoconf \ 45 | automake \ 46 | autotools-dev \ 47 | bison \ 48 | build-essential \ 49 | ca-certificates \ 50 | cmake \ 51 | g++ \ 52 | git \ 53 | libboost-all-dev \ 54 | libcurl4-gnutls-dev \ 55 | libgmp-dev \ 56 | libjson-c-dev \ 57 | libmpfr-dev \ 58 | libpcre3-dev \ 59 | libpq-dev \ 60 | libprotobuf-c-dev \ 61 | libsqlite3-dev \ 62 | libtiff-dev \ 63 | libtool \ 64 | libxml2-dev \ 65 | make \ 66 | pkg-config \ 67 | protobuf-c-compiler \ 68 | xsltproc \ 69 | # gdal+ 70 | libblosc-dev \ 71 | libcfitsio-dev \ 72 | libfreexl-dev \ 73 | libfyba-dev \ 74 | libhdf5-dev \ 75 | libkml-dev \ 76 | liblz4-dev \ 77 | liblzma-dev \ 78 | libopenjp2-7-dev \ 79 | libqhull-dev \ 80 | libwebp-dev \ 81 | libzstd-dev 82 | 83 | ARG DOCKER_CMAKE_BUILD_TYPE 84 | ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} 85 | 86 | # cgal & sfcgal 87 | ARG CGAL_GIT_BRANCH 88 | ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} 89 | ENV CGAL_GIT_HASH %%CGAL_GIT_HASH%% 90 | ENV SFCGAL_GIT_HASH %%SFCGAL_GIT_HASH%% 91 | RUN set -ex \ 92 | && mkdir -p /usr/src \ 93 | && cd /usr/src \ 94 | && git clone --branch ${CGAL_GIT_BRANCH} https://github.com/CGAL/cgal \ 95 | && cd cgal \ 96 | && git checkout ${CGAL_GIT_HASH} \ 97 | && git log -1 > /_pgis_cgal_last_commit.txt \ 98 | && cd /usr/src \ 99 | && git clone https://gitlab.com/SFCGAL/SFCGAL.git \ 100 | && cd SFCGAL \ 101 | && git checkout ${SFCGAL_GIT_HASH} \ 102 | && git log -1 > /_pgis_sfcgal_last_commit.txt \ 103 | && mkdir cmake-build \ 104 | && cd cmake-build \ 105 | && cmake .. \ 106 | -DCGAL_DIR=/usr/src/cgal \ 107 | -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} \ 108 | -DSFCGAL_BUILD_BENCH=OFF \ 109 | -DSFCGAL_BUILD_EXAMPLES=OFF \ 110 | -DSFCGAL_BUILD_TESTS=OFF \ 111 | -DSFCGAL_WITH_OSG=OFF \ 112 | && make -j$(nproc) \ 113 | && make install \ 114 | # 115 | ## testing with -DSFCGAL_BUILD_TESTS=ON 116 | # && CTEST_OUTPUT_ON_FAILURE=TRUE ctest \ 117 | # 118 | # clean 119 | && rm -fr /usr/src/SFCGAL \ 120 | && rm -fr /usr/src/cgal 121 | 122 | # proj 123 | ENV PROJ_GIT_HASH %%PROJ_GIT_HASH%% 124 | RUN set -ex \ 125 | && cd /usr/src \ 126 | && git clone https://github.com/OSGeo/PROJ.git \ 127 | && cd PROJ \ 128 | && git checkout ${PROJ_GIT_HASH} \ 129 | && git log -1 > /_pgis_proj_last_commit.txt \ 130 | # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 131 | && if [ -f "autogen.sh" ] ; then \ 132 | set -eux \ 133 | && echo "autotools version: 'autogen.sh' exists! Older version!" \ 134 | && ./autogen.sh \ 135 | && ./configure --disable-static \ 136 | && make -j$(nproc) \ 137 | && make install \ 138 | ; \ 139 | else \ 140 | set -eux \ 141 | && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ 142 | && mkdir build \ 143 | && cd build \ 144 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 145 | && make -j$(nproc) \ 146 | && make install \ 147 | ; \ 148 | fi \ 149 | \ 150 | && rm -fr /usr/src/PROJ 151 | 152 | # geos 153 | ENV GEOS_GIT_HASH %%GEOS_GIT_HASH%% 154 | RUN set -ex \ 155 | && cd /usr/src \ 156 | && git clone https://github.com/libgeos/geos.git \ 157 | && cd geos \ 158 | && git checkout ${GEOS_GIT_HASH} \ 159 | && git log -1 > /_pgis_geos_last_commit.txt \ 160 | && mkdir cmake-build \ 161 | && cd cmake-build \ 162 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 163 | && make -j$(nproc) \ 164 | && make install \ 165 | && cd / \ 166 | && rm -fr /usr/src/geos 167 | 168 | # gdal 169 | ENV GDAL_GIT_HASH %%GDAL_GIT_HASH%% 170 | RUN set -ex \ 171 | && cd /usr/src \ 172 | && git clone https://github.com/OSGeo/gdal.git \ 173 | && cd gdal \ 174 | && git checkout ${GDAL_GIT_HASH} \ 175 | && git log -1 > /_pgis_gdal_last_commit.txt \ 176 | \ 177 | # gdal project directory structure - has been changed ! 178 | && if [ -d "gdal" ] ; then \ 179 | echo "Directory 'gdal' dir exists -> older version!" ; \ 180 | cd gdal ; \ 181 | else \ 182 | echo "Directory 'gdal' does not exists! Newer version! " ; \ 183 | fi \ 184 | \ 185 | && if [ -f "./autogen.sh" ]; then \ 186 | # Building with autoconf ( old/deprecated ) 187 | set -eux \ 188 | && ./autogen.sh \ 189 | && ./configure --disable-static \ 190 | ; \ 191 | else \ 192 | # Building with cmake 193 | set -eux \ 194 | && mkdir build \ 195 | && cd build \ 196 | # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules 197 | && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ 198 | -DBUILD_DOCS=OFF \ 199 | \ 200 | -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ 201 | -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ 202 | -DGDAL_USE_BLOSC=ON \ 203 | -DGDAL_USE_CFITSIO=ON \ 204 | -DGDAL_USE_CURL=ON \ 205 | -DGDAL_USE_DEFLATE=ON \ 206 | -DGDAL_USE_EXPAT=ON \ 207 | -DGDAL_USE_FREEXL=ON \ 208 | -DGDAL_USE_FYBA=ON \ 209 | -DGDAL_USE_GEOS=ON \ 210 | -DGDAL_USE_HDF5=ON \ 211 | -DGDAL_USE_JSONC=ON \ 212 | -DGDAL_USE_LERC_INTERNAL=ON \ 213 | -DGDAL_USE_LIBKML=ON \ 214 | -DGDAL_USE_LIBLZMA=ON \ 215 | -DGDAL_USE_LZ4=ON \ 216 | -DGDAL_USE_OPENJPEG=ON \ 217 | -DGDAL_USE_POSTGRESQL=ON \ 218 | -DGDAL_USE_QHULL=ON \ 219 | -DGDAL_USE_SQLITE3=ON \ 220 | -DGDAL_USE_TIFF=ON \ 221 | -DGDAL_USE_WEBP=ON \ 222 | -DGDAL_USE_ZSTD=ON \ 223 | \ 224 | # OFF and Not working https://github.com/OSGeo/gdal/issues/7100 225 | # -DRENAME_INTERNAL_GEOTIFF_SYMBOLS=ON \ 226 | -DGDAL_USE_ECW=OFF \ 227 | -DGDAL_USE_GEOTIFF=OFF \ 228 | -DGDAL_USE_HEIF=OFF \ 229 | -DGDAL_USE_SPATIALITE=OFF \ 230 | ; \ 231 | fi \ 232 | \ 233 | && make -j$(nproc) \ 234 | && make install \ 235 | && cd / \ 236 | && rm -fr /usr/src/gdal 237 | 238 | # Minimal command line test. 239 | RUN set -ex \ 240 | && ldconfig \ 241 | && cs2cs \ 242 | && ldd $(which gdalinfo) \ 243 | && gdalinfo --version \ 244 | && geos-config --version \ 245 | && ogr2ogr --version \ 246 | && proj \ 247 | && sfcgal-config --version \ 248 | && pcre-config --version 249 | 250 | # ------------------------------------------- 251 | # STAGE final 252 | # ------------------------------------------- 253 | FROM postgres:%%PG_MAJOR%%-%%DEBIAN_VERSION%% 254 | 255 | ARG DOCKER_CMAKE_BUILD_TYPE 256 | ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} 257 | 258 | RUN set -ex \ 259 | && apt-get update \ 260 | && apt-get install -y --no-install-recommends \ 261 | curl \ 262 | libboost-atomic%%BOOST_VERSION%% \ 263 | libboost-chrono%%BOOST_VERSION%% \ 264 | libboost-date-time%%BOOST_VERSION%% \ 265 | libboost-filesystem%%BOOST_VERSION%% \ 266 | libboost-program-options%%BOOST_VERSION%% \ 267 | libboost-serialization%%BOOST_VERSION%% \ 268 | libboost-system%%BOOST_VERSION%% \ 269 | libboost-test%%BOOST_VERSION%% \ 270 | libboost-thread%%BOOST_VERSION%% \ 271 | libboost-timer%%BOOST_VERSION%% \ 272 | libcurl3-gnutls \ 273 | libexpat1 \ 274 | libgmp10 \ 275 | libgmpxx4ldbl \ 276 | libjson-c5 \ 277 | libmpfr6 \ 278 | libpcre3 \ 279 | libprotobuf-c1 \ 280 | libtiff5 \ 281 | libxml2 \ 282 | sqlite3 \ 283 | # gdal+ 284 | libblosc1 \ 285 | libcfitsio9 \ 286 | libfreexl1 \ 287 | libfyba0 \ 288 | libhdf5-103-1 \ 289 | libkmlbase1 \ 290 | libkmldom1 \ 291 | libkmlengine1 \ 292 | libopenjp2-7 \ 293 | libqhull-r8.0 \ 294 | && apt-get clean \ 295 | && rm -rf /var/lib/apt/lists/* 296 | 297 | COPY --from=builder /_pgis*.* / 298 | COPY --from=builder /usr/local /usr/local 299 | 300 | ARG CGAL_GIT_BRANCH 301 | ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} 302 | ENV CGAL_GIT_HASH %%CGAL_GIT_HASH%% 303 | ENV SFCGAL_GIT_HASH %%SFCGAL_GIT_HASH%% 304 | ENV PROJ_GIT_HASH %%PROJ_GIT_HASH%% 305 | ENV GEOS_GIT_HASH %%GEOS_GIT_HASH%% 306 | ENV GDAL_GIT_HASH %%GDAL_GIT_HASH%% 307 | 308 | # Minimal command line test ( fail fast ) 309 | RUN set -ex \ 310 | && ldconfig \ 311 | && cs2cs \ 312 | && ldd $(which gdalinfo) \ 313 | && gdalinfo --version \ 314 | && gdal-config --formats \ 315 | && geos-config --version \ 316 | && ogr2ogr --version \ 317 | && proj \ 318 | && sfcgal-config --version \ 319 | \ 320 | # Testing ogr2ogr PostgreSQL driver. 321 | && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ 322 | || echo "ogr2ogr missing PostgreSQL driver" && exit 1 323 | 324 | # install postgis 325 | ENV POSTGIS_GIT_HASH %%POSTGIS_GIT_HASH%% 326 | 327 | RUN set -ex \ 328 | && apt-get update \ 329 | && apt-get install -y --no-install-recommends \ 330 | autoconf \ 331 | automake \ 332 | autotools-dev \ 333 | bison \ 334 | build-essential \ 335 | ca-certificates \ 336 | cmake \ 337 | docbook-xml \ 338 | docbook5-xml \ 339 | g++ \ 340 | git \ 341 | libboost-all-dev \ 342 | libcunit1-dev \ 343 | libcurl4-gnutls-dev \ 344 | libgmp-dev \ 345 | libjson-c-dev \ 346 | libmpfr-dev \ 347 | libpcre3-dev \ 348 | libprotobuf-c-dev \ 349 | libsqlite3-dev \ 350 | libtiff-dev \ 351 | libtool \ 352 | libxml2-dev \ 353 | libxml2-utils \ 354 | make \ 355 | pkg-config \ 356 | postgresql-server-dev-$PG_MAJOR \ 357 | protobuf-c-compiler \ 358 | xsltproc \ 359 | && cd \ 360 | # postgis 361 | && cd /usr/src/ \ 362 | && git clone https://github.com/postgis/postgis.git \ 363 | && cd postgis \ 364 | && git checkout ${POSTGIS_GIT_HASH} \ 365 | && git log -1 > /_pgis_last_commit.txt \ 366 | && ./autogen.sh \ 367 | # configure options taken from: 368 | # https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie 369 | && ./configure \ 370 | --enable-lto \ 371 | && make -j$(nproc) \ 372 | && make install \ 373 | # refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 374 | && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ 375 | && projsync --system-directory --file us_noaa_eshpgn \ 376 | && projsync --system-directory --file us_noaa_prvi \ 377 | && projsync --system-directory --file us_noaa_wmhpgn \ 378 | # regress check 379 | && mkdir /tempdb \ 380 | && chown -R postgres:postgres /tempdb \ 381 | && su postgres -c 'pg_ctl -D /tempdb init' \ 382 | && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ 383 | && ldconfig \ 384 | && cd regress \ 385 | && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ 386 | \ 387 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ 388 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ 389 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ 390 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ 391 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ 392 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ 393 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ 394 | && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ 395 | && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ 396 | && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ 397 | && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ 398 | \ 399 | && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ 400 | && rm -rf /tempdb \ 401 | && rm -rf /tmp/logfile \ 402 | && rm -rf /tmp/pgis_reg \ 403 | # clean 404 | && cd / \ 405 | && rm -rf /usr/src/postgis \ 406 | && apt-get purge -y --autoremove \ 407 | autoconf \ 408 | automake \ 409 | autotools-dev \ 410 | bison \ 411 | build-essential \ 412 | cmake \ 413 | docbook-xml \ 414 | docbook5-xml \ 415 | g++ \ 416 | git \ 417 | libboost-all-dev \ 418 | libcurl4-gnutls-dev \ 419 | libgmp-dev \ 420 | libjson-c-dev \ 421 | libmpfr-dev \ 422 | libpcre3-dev \ 423 | libprotobuf-c-dev \ 424 | libsqlite3-dev \ 425 | libtiff-dev \ 426 | libtool \ 427 | libxml2-dev \ 428 | libxml2-utils \ 429 | make \ 430 | pkg-config \ 431 | postgresql-server-dev-$PG_MAJOR \ 432 | protobuf-c-compiler \ 433 | xsltproc \ 434 | && apt-get clean \ 435 | && rm -rf /var/lib/apt/lists/* 436 | 437 | RUN mkdir -p /docker-entrypoint-initdb.d 438 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 439 | COPY ./update-postgis.sh /usr/local/bin 440 | 441 | # last final test 442 | RUN set -ex \ 443 | && ldconfig \ 444 | && cs2cs \ 445 | && ldd $(which gdalinfo) \ 446 | && gdalinfo --version \ 447 | && gdal-config --formats \ 448 | && geos-config --version \ 449 | && ogr2ogr --version \ 450 | && proj \ 451 | && sfcgal-config --version \ 452 | \ 453 | # Is the "ca-certificates" package installed? (for accessing remote raster files) 454 | # https://github.com/postgis/docker-postgis/issues/307 455 | && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ 456 | \ 457 | # list last commits. 458 | && find /_pgis_*_last_commit.txt -type f -print -exec cat {} \; \ 459 | # list postgresql, postgis version 460 | && cat _pgis_full_version.txt 461 | -------------------------------------------------------------------------------- /Dockerfile.template: -------------------------------------------------------------------------------- 1 | # 2 | # %%TXT_AUTOGENERATED%% 3 | # 4 | 5 | FROM postgres:%%PG_MAJOR%%-%%DEBIAN_VERSION%% 6 | 7 | LABEL maintainer="PostGIS Project - https://postgis.net" \ 8 | org.opencontainers.image.description="PostGIS %%POSTGIS_VERSION%% spatial database extension with PostgreSQL %%PG_MAJOR%% %%DEBIAN_VERSION%%" \ 9 | org.opencontainers.image.source="https://github.com/postgis/docker-postgis" 10 | 11 | ENV POSTGIS_MAJOR %%POSTGIS_MAJOR%% 12 | ENV POSTGIS_VERSION %%POSTGIS_VERSION%% 13 | 14 | RUN apt-get update \ 15 | && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ 16 | && apt-get install -y --no-install-recommends \ 17 | # ca-certificates: for accessing remote raster files; 18 | # fix: https://github.com/postgis/docker-postgis/issues/307 19 | ca-certificates \ 20 | \ 21 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ 22 | postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | RUN mkdir -p /docker-entrypoint-initdb.d 26 | COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh 27 | COPY ./update-postgis.sh /usr/local/bin 28 | 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Docker PostGIS Authors (See AUTHORS) 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | # When processing the rules for tagging and pushing container images with the 3 | # "latest" tag, the following variable will be the version that is considered 4 | # to be the latest. 5 | LATEST_VERSION=17-3.5 6 | 7 | # The following flags are set based on VERSION and VARIANT environment variables 8 | # that may have been specified, and are used by rules to determine which 9 | # versions/variants are to be processed. If no VERSION or VARIANT environment 10 | # variables were specified, process everything (the default). 11 | do_default=true 12 | do_alpine=true 13 | 14 | # The following logic evaluates VERSION and VARIANT variables that may have 15 | # been previously specified, and modifies the "do" flags depending on the values. 16 | # The VERSIONS variable is also set to contain the version(s) to be processed. 17 | ifdef VERSION 18 | VERSIONS=$(VERSION) # If a version was specified, VERSIONS only contains the specified version 19 | ifdef VARIANT # If a variant is specified, unset all do flags and allow subsequent logic to set them again where appropriate 20 | do_default=false 21 | do_alpine=false 22 | ifeq ($(VARIANT),default) 23 | do_default=true 24 | endif 25 | ifeq ($(VARIANT),alpine) 26 | do_alpine=true 27 | endif 28 | endif 29 | ifeq ("$(wildcard $(VERSION)/alpine)","") # If no alpine subdirectory exists, don't process the alpine version 30 | do_alpine=false 31 | endif 32 | else # If no version was specified, VERSIONS should contain all versions 33 | VERSIONS = $(foreach df,$(wildcard */Dockerfile),$(df:%/Dockerfile=%)) 34 | endif 35 | 36 | # The "latest" tag will only be provided for default images (no variant) so 37 | # only define the dependencies when the default image will be built. 38 | ifeq ($(do_default),true) 39 | BUILD_LATEST_DEP=build-$(LATEST_VERSION) 40 | PUSH_LATEST_DEP=push-$(LATEST_VERSION) 41 | PUSH_DEP=push-latest $(PUSH_LATEST_DEP) 42 | # The "latest" tag shouldn't be processed if a VERSION was explicitly 43 | # specified but does not correspond to the latest version. 44 | ifdef VERSION 45 | ifneq ($(VERSION),$(LATEST_VERSION)) 46 | PUSH_LATEST_DEP= 47 | BUILD_LATEST_DEP= 48 | PUSH_DEP= 49 | endif 50 | endif 51 | endif 52 | 53 | # The repository and image names default to the official but can be overriden 54 | # via environment variables. 55 | REPO_NAME ?= postgis 56 | IMAGE_NAME ?= postgis 57 | 58 | DOCKER=docker 59 | DOCKERHUB_DESC_IMG=peterevans/dockerhub-description:latest 60 | 61 | GIT=git 62 | OFFIMG_LOCAL_CLONE=$(HOME)/official-images 63 | OFFIMG_REPO_URL=https://github.com/docker-library/official-images.git 64 | 65 | 66 | build: $(foreach version,$(VERSIONS),build-$(version)) 67 | 68 | all: update build test 69 | 70 | update: 71 | $(DOCKER) run --rm -v $$(pwd):/work -w /work buildpack-deps ./update.sh 72 | 73 | 74 | ### RULES FOR BUILDING ### 75 | 76 | define build-version 77 | build-$1: 78 | ifeq ($(do_default),true) 79 | $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) $1 80 | $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) 81 | endif 82 | ifeq ($(do_alpine),true) 83 | ifneq ("$(wildcard $1/alpine)","") 84 | $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine $1/alpine 85 | $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine 86 | endif 87 | endif 88 | endef 89 | $(foreach version,$(VERSIONS),$(eval $(call build-version,$(version)))) 90 | 91 | 92 | ## RULES FOR TESTING ### 93 | 94 | test-prepare: 95 | ifeq ("$(wildcard $(OFFIMG_LOCAL_CLONE))","") 96 | $(GIT) clone $(OFFIMG_REPO_URL) $(OFFIMG_LOCAL_CLONE) 97 | endif 98 | 99 | test: $(foreach version,$(VERSIONS),test-$(version)) 100 | 101 | define test-version 102 | test-$1: test-prepare build-$1 103 | ifeq ($(do_default),true) 104 | $(OFFIMG_LOCAL_CLONE)/test/run.sh -c $(OFFIMG_LOCAL_CLONE)/test/config.sh -c test/postgis-config.sh $(REPO_NAME)/$(IMAGE_NAME):$(version) 105 | endif 106 | ifeq ($(do_alpine),true) 107 | ifneq ("$(wildcard $1/alpine)","") 108 | $(OFFIMG_LOCAL_CLONE)/test/run.sh -c $(OFFIMG_LOCAL_CLONE)/test/config.sh -c test/postgis-config.sh $(REPO_NAME)/$(IMAGE_NAME):$(version)-alpine 109 | endif 110 | endif 111 | endef 112 | $(foreach version,$(VERSIONS),$(eval $(call test-version,$(version)))) 113 | 114 | 115 | ### RULES FOR TAGGING ### 116 | 117 | tag-latest: $(BUILD_LATEST_DEP) 118 | $(DOCKER) image tag $(REPO_NAME)/$(IMAGE_NAME):$(LATEST_VERSION) $(REPO_NAME)/$(IMAGE_NAME):latest 119 | 120 | 121 | ### RULES FOR PUSHING ### 122 | 123 | push: $(foreach version,$(VERSIONS),push-$(version)) $(PUSH_DEP) 124 | 125 | define push-version 126 | push-$1: test-$1 127 | ifeq ($(do_default),true) 128 | $(DOCKER) image push $(REPO_NAME)/$(IMAGE_NAME):$(version) 129 | endif 130 | ifeq ($(do_alpine),true) 131 | ifneq ("$(wildcard $1/alpine)","") 132 | $(DOCKER) image push $(REPO_NAME)/$(IMAGE_NAME):$(version)-alpine 133 | endif 134 | endif 135 | endef 136 | $(foreach version,$(VERSIONS),$(eval $(call push-version,$(version)))) 137 | 138 | push-latest: tag-latest $(PUSH_LATEST_DEP) 139 | $(DOCKER) image push $(REPO_NAME)/$(IMAGE_NAME):latest 140 | @$(DOCKER) run -v "$(PWD)":/workspace \ 141 | -e DOCKERHUB_USERNAME='$(DOCKERHUB_USERNAME)' \ 142 | -e DOCKERHUB_PASSWORD='$(DOCKERHUB_ACCESS_TOKEN)' \ 143 | -e DOCKERHUB_REPOSITORY='$(REPO_NAME)/$(IMAGE_NAME)' \ 144 | -e README_FILEPATH='/workspace/README.md' $(DOCKERHUB_DESC_IMG) 145 | 146 | 147 | .PHONY: build all update test-prepare test tag-latest push push-latest \ 148 | $(foreach version,$(VERSIONS),build-$(version)) \ 149 | $(foreach version,$(VERSIONS),test-$(version)) \ 150 | $(foreach version,$(VERSIONS),push-$(version)) 151 | 152 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # postgis/postgis 2 | 3 | [![Build Status](https://github.com/postgis/docker-postgis/workflows/Docker%20PostGIS%20CI/badge.svg)](https://github.com/postgis/docker-postgis/actions) [![Join the chat at https://gitter.im/postgis/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/postgis/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | 5 | The `postgis/postgis` image provides tags for running Postgres with [PostGIS](http://postgis.net/) extensions installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for PostGIS 3.5.x, which is compatible with PostgreSQL versions 13, 14, 15, 16 and 17. Additionally, an image version is provided which is built from the latest two versions of Postgres (16, 17) with versions of PostGIS and its dependencies built from their respective master branches. 6 | 7 | This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: 8 | 9 | | installed extensions | [initialized](https://github.com/postgis/docker-postgis/blob/master/initdb-postgis.sh)| 10 | |---------------------|-----| 11 | | `postgis` | yes | 12 | | `postgis_topology` | yes | 13 | | `postgis_tiger_geocoder` | yes | 14 | | `postgis_raster` | | 15 | | `postgis_sfcgal` | | 16 | | `address_standardizer`| | 17 | | `address_standardizer_data_us`| | 18 | 19 | Unless `-e POSTGRES_DB` is passed to the container at startup time, this database will be named after the admin user (either `postgres` or the user specified with `-e POSTGRES_USER`). If you would prefer to use the older template database mechanism for enabling PostGIS, the image also provides a PostGIS-enabled template database called `template_postgis`. 20 | 21 | # Versions (2025-06-05) 22 | 23 | Supported architecture: `amd64` (also known as X86-64)" 24 | 25 | Recommended versions for new users are: `postgis/postgis:17-3.5`, `postgis/postgis:16-3.5` 26 | 27 | ### Debian based (recommended) 28 | 29 | * This Docker-PostGIS version has a cautious release cycle to guarantee high stability. 30 | * By "cautious", we mean it does not always have the latest versions of geos, proj, gdal, and sfcgal packages. 31 | * We use PostGIS, geos, proj, gdal, and sfcgal packages from the Debian repository. 32 | * In the Debian Bullseye repository, the versions are: geos=3.9, gdal=3.2, proj=7.2, and sfcgal=1.3.9. 33 | * This version is easy to extend and has matured over time. 34 | 35 | | DockerHub image | Dockerfile | OS | Postgres | PostGIS | 36 | | --------------- | ---------- | -- | -------- | ------- | 37 | | [postgis/postgis:13-3.5](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=13-3.5) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/13-3.5/Dockerfile) | debian:bullseye | 13 | 3.5.2 | 38 | | [postgis/postgis:14-3.5](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=14-3.5) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/14-3.5/Dockerfile) | debian:bullseye | 14 | 3.5.2 | 39 | | [postgis/postgis:15-3.5](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=15-3.5) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/15-3.5/Dockerfile) | debian:bullseye | 15 | 3.5.2 | 40 | | [postgis/postgis:16-3.5](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-3.5) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/16-3.5/Dockerfile) | debian:bullseye | 16 | 3.5.2 | 41 | | [postgis/postgis:17-3.5](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-3.5) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/17-3.5/Dockerfile) | debian:bullseye | 17 | 3.5.2 | 42 | 43 | ### Alpine based 44 | 45 | * The base operating system is [Alpine Linux](https://alpinelinux.org/). It is designed to be small, simple, and secure, and it's based on [musl libc](https://musl.libc.org/). 46 | * In the Alpine 3.22 version, the package versions are: geos=3.13.1, gdal=3.10.2, proj=9.6.0, and sfcgal=2.0.0 47 | * PostGIS is compiled from source, making it a bit more challenging to extend. 48 | 49 | | DockerHub image | Dockerfile | OS | Postgres | PostGIS | 50 | | --------------- | ---------- | -- | -------- | ------- | 51 | | [postgis/postgis:13-3.5-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=13-3.5-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/13-3.5/alpine/Dockerfile) | alpine:3.22 | 13 | 3.5.3 | 52 | | [postgis/postgis:14-3.5-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=14-3.5-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/14-3.5/alpine/Dockerfile) | alpine:3.22 | 14 | 3.5.3 | 53 | | [postgis/postgis:15-3.5-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=15-3.5-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/15-3.5/alpine/Dockerfile) | alpine:3.22 | 15 | 3.5.3 | 54 | | [postgis/postgis:16-3.5-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-3.5-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/16-3.5/alpine/Dockerfile) | alpine:3.22 | 16 | 3.5.3 | 55 | | [postgis/postgis:17-3.5-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-3.5-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/17-3.5/alpine/Dockerfile) | alpine:3.22 | 17 | 3.5.3 | 56 | 57 | ### Test images 58 | 59 | * We provide alpha, beta, release candidate (rc), and development (identified as ~master) versions. 60 | * The template for the `*-master` images is updated manually, which might lead to a delay of a few weeks sometimes. 61 | 62 | | DockerHub image | Dockerfile | OS | Postgres | PostGIS | 63 | | --------------- | ---------- | -- | -------- | ------- | 64 | | [postgis/postgis:16-master](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-master) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/16-master/Dockerfile) | debian:bullseye | 16 | development: postgis, geos, proj, gdal | 65 | | [postgis/postgis:17-3.6.0alpha1-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-3.6.0alpha1-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/17-3.6.0alpha1/alpine/Dockerfile) | alpine:3.22 | 17 | 3.6.0alpha1 | 66 | | [postgis/postgis:17-master](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-master) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/17-master/Dockerfile) | debian:bullseye | 17 | development: postgis, geos, proj, gdal | 67 | 68 | ## Usage 69 | 70 | In order to run a basic container capable of serving a PostGIS-enabled database, start a container as follows: 71 | 72 | docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis 73 | 74 | For more detailed instructions about how to start and control your Postgres container, see the documentation for the `postgres` image [here](https://registry.hub.docker.com/_/postgres/). 75 | 76 | Once you have started a database container, you can then connect to the database either directly on the running container: 77 | 78 | docker exec -ti some-postgis psql -U postgres 79 | 80 | ... or starting a new container to run as a client. In this case you can use a user-defined network to link both containers: 81 | 82 | docker network create some-network 83 | 84 | # Server container 85 | docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis 86 | 87 | # Client container 88 | docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres 89 | 90 | Check the documentation on the [`postgres` image](https://registry.hub.docker.com/_/postgres/) and [Docker networking](https://docs.docker.com/network/) for more details and alternatives on connecting different containers. 91 | 92 | See [the PostGIS documentation](http://postgis.net/docs/postgis_installation.html#create_new_db_extensions) for more details on your options for creating and using a spatially-enabled database. 93 | 94 | ## Supported Environment Variables: 95 | 96 | Since the docker-postgis repository is an extension of the official Docker PostgreSQL repository, all environment variables supported there are also supported here: 97 | 98 | * `POSTGRES_PASSWORD` 99 | * `POSTGRES_USER` 100 | * `POSTGRES_DB` 101 | * `POSTGRES_INITDB_ARGS` 102 | * `POSTGRES_INITDB_WALDIR` 103 | * `POSTGRES_HOST_AUTH_METHOD` 104 | * `PGDATA` 105 | 106 | Read more: https://github.com/docker-library/docs/blob/master/postgres/README.md 107 | 108 | Warning: **the Docker specific variables will only have an effect if you start the container with a data directory that is empty;** any pre-existing database will be left untouched on container startup. 109 | 110 | It's important to note that the environment variables for the Docker image are different from those of the [libpq — C Library](https://www.postgresql.org/docs/current/libpq-envars.html) (`PGDATABASE`,`PGUSER`,`PGPASSWORD` ) 111 | 112 | ## Troubleshooting tips: 113 | 114 | Troubleshooting can often be challenging. It's important to know that the docker-postgis repository is an extension of the official Docker PostgreSQL repository. Therefore, if you encounter any issues, it's worth testing whether the problem can be reproduced with the [official PostgreSQL Docker images](https://hub.docker.com/_/postgres). If so, it's recommended to search for solutions based on this. The following websites are suggested: 115 | 116 | * Upstream docker postgres repo: https://github.com/docker-library/postgres 117 | * search for the open or closed issues ! 118 | * Docker Community Forums: https://forums.docker.com 119 | * Docker Community Slack: https://dockr.ly/slack 120 | * Stack Overflow: https://stackoverflow.com/questions/tagged/docker+postgresql 121 | 122 | If your problem is Postgis related: 123 | 124 | * Stack Overflow : docker + postgis https://stackoverflow.com/questions/tagged/docker+postgis 125 | * Postgis issue tracker: https://trac.osgeo.org/postgis/report 126 | 127 | And if you don't have a postgres docker experience - read this blog post: 128 | 129 | * https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/ 130 | 131 | 132 | ## Security 133 | 134 | It's crucial to be aware that in a cloud environment, with default settings, these images are vulnerable, and there's a high risk of cryptominer infection if the ports are left open. ( [Read More](https://github.com/docker-library/postgres/issues/770#issuecomment-704460980) ) 135 | * Note that ports which are not bound to the host (i.e., `-p 5432:5432` instead of `-p 127.0.0.1:5432:5432`) will be accessible from the outside. This also applies if you configured UFW to block this specific port, as Docker manages its own iptables rules. ( [Read More](https://docs.docker.com/network/iptables/) ) 136 | 137 | #### Recomendations: 138 | * You can add options for using SSL ( [see postgres example](https://github.com/docker-library/postgres/issues/989#issuecomment-1222648067) ) 139 | - `-c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key` 140 | * Or you can use [SSH Tunnels](https://www.postgresql.org/docs/15/ssh-tunnels.html) with `-p 127.0.0.1:5432:5432` 141 | 142 | #### Security scanner information: 143 | 144 | - Please also scan the base `postgres` docker Image: 145 | It's important to also scan the base `postgres` Docker image for potential security issues. If your security scanner reports vulnerabilities (known as CVEs) in the image, you may wonder why. To get a better understanding, please read the Docker Library FAQ, especially the section titled ["Why does my security scanner show that an image has CVEs?"](https://github.com/docker-library/faq#why-does-my-security-scanner-show-that-an-image-has-cves) 146 | For more specific issues related to the postgres docker image, you can search using these links: 147 | - [search for repo:docker-library/postgres trivy](https://github.com/search?q=repo%3Adocker-library%2Fpostgres+trivy&type=issues) 148 | - [search for repo:docker-library/postgres CVE](https://github.com/search?q=repo%3Adocker-library%2Fpostgres+CVE&type=issues) 149 | 150 | - Optimizing Security Scans: 151 | It's advisable to focus on scanning and fixing issues that can be resolved. 152 | Use this command to scan for fixable issues only: 153 | * `trivy image --ignore-unfixed postgis/postgis:16-3.5-alpine` 154 | * `trivy image --ignore-unfixed postgres:16-alpine` 155 | For more details, you can read this article: https://pythonspeed.com/articles/docker-security-scanner/ 156 | 157 | #### Limitations on Updates: 158 | Unfortunately, we don't have control over updates to Debian and Alpine distributions or the upstream `postgres` image. 159 | Because of this, there might be some issues that we cannot fix right away. 160 | On the positive side, the `postgis/postgis` images are regenerated every Monday. This process is to ensure they include the latest changes and improvements. As a result, these images are consistently kept up-to-date. 161 | 162 | #### Suggestions Welcome: 163 | We are always open to suggestions to enhance security. If you have any ideas, please let us know. 164 | 165 | ## Known Issues / Errors 166 | 167 | When You encouter errors due to PostGIS update `OperationalError: could not access file "$libdir/postgis-X.X`, run: 168 | 169 | `docker exec some-postgis update-postgis.sh` 170 | 171 | It will update to Your newest PostGIS. Update is idempotent, so it won't hurt when You run it more than once, You will get notification like: 172 | 173 | ``` 174 | Updating PostGIS extensions template_postgis to X.X.X 175 | NOTICE: version "X.X.X" of extension "postgis" is already installed 176 | NOTICE: version "X.X.X" of extension "postgis_topology" is already installed 177 | NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed 178 | ALTER EXTENSION 179 | Updating PostGIS extensions docker to X.X.X 180 | NOTICE: version "X.X.X" of extension "postgis" is already installed 181 | NOTICE: version "X.X.X" of extension "postgis_topology" is already installed 182 | NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed 183 | ALTER EXTENSION 184 | ``` 185 | 186 | ## Contributor guideline 187 | 188 | This Docker-PostGIS project [is part of the PostGIS group](https://postgis.net/development/rfcs/rfc05/#projects-under-postgis-umbrella) and follows more flexible contributor rules. 189 | 190 | * Please take a moment to review the current issues, discussions, and pull requests before you start. 191 | * If you have a major change in mind, we kindly ask you to start a discussion about it first. 192 | * After making changes to the templates, please run the `./update.sh` script. 193 | 194 | ## Code of Conduct 195 | 196 | see: https://postgis.net/community/conduct/ 197 | -------------------------------------------------------------------------------- /examples/image-with-postgis-clis/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM postgis/postgis:13-3.1 2 | 3 | RUN apt-get update -y 4 | RUN apt-get install postgis -y 5 | RUN apt-get clean 6 | RUN rm -rf /var/cache/apt/lists -------------------------------------------------------------------------------- /examples/image-with-postgis-clis/README.md: -------------------------------------------------------------------------------- 1 | # Using PostGIS CLIs 2 | The base postgis/postgis image does not have PostGIS-related CLIs installed. To use PostGIS CLIs that are NOT installed by default (for example `raster2pgsql`) it's necessary to extend the base image. 3 | 4 | ```sh 5 | # Create a Docker image 6 | docker build -t my-postgis . 7 | 8 | # Run as a Docker container 9 | docker run --name my-postgis -p 5432:5432 -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=password -d my-postgis 10 | ``` -------------------------------------------------------------------------------- /initdb-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | # Create the 'template_postgis' template db 9 | "${psql[@]}" <<- 'EOSQL' 10 | CREATE DATABASE template_postgis IS_TEMPLATE true; 11 | EOSQL 12 | 13 | # Load PostGIS into both template_database and $POSTGRES_DB 14 | for DB in template_postgis "$POSTGRES_DB"; do 15 | echo "Loading PostGIS extensions into $DB" 16 | "${psql[@]}" --dbname="$DB" <<-'EOSQL' 17 | CREATE EXTENSION IF NOT EXISTS postgis; 18 | CREATE EXTENSION IF NOT EXISTS postgis_topology; 19 | -- Reconnect to update pg_setting.resetval 20 | -- See https://github.com/postgis/docker-postgis/issues/288 21 | \c 22 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 23 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; 24 | EOSQL 25 | done 26 | -------------------------------------------------------------------------------- /test/postgis-config.sh: -------------------------------------------------------------------------------- 1 | testAlias[postgis/postgis]=postgres 2 | 3 | imageTests[postgis/postgis]=' 4 | postgis-basics 5 | ' 6 | -------------------------------------------------------------------------------- /test/tests/postgis-basics/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | image="$1" 5 | 6 | export POSTGRES_USER='my cool postgres user' 7 | export POSTGRES_PASSWORD='my cool postgres password' 8 | export POSTGRES_DB='my cool postgres database' 9 | 10 | cname="postgis-container-$RANDOM-$RANDOM" 11 | cid="$(docker run -d -e POSTGRES_USER -e POSTGRES_PASSWORD -e POSTGRES_DB --name "$cname" "$image")" 12 | trap "docker rm -vf $cid > /dev/null" EXIT 13 | 14 | psql() { 15 | docker run --rm -i \ 16 | --link "$cname":postgis \ 17 | --entrypoint psql \ 18 | -e PGPASSWORD="$POSTGRES_PASSWORD" \ 19 | "$image" \ 20 | --host postgis \ 21 | --username "$POSTGRES_USER" \ 22 | --dbname "$POSTGRES_DB" \ 23 | --quiet --no-align --tuples-only \ 24 | "$@" 25 | } 26 | 27 | tries=10 28 | while ! echo 'SELECT 1' | psql &> /dev/null; do 29 | (( tries-- )) 30 | if [ $tries -le 0 ]; then 31 | echo >&2 'postgres failed to accept connections in a reasonable amount of time!' 32 | echo 'SELECT 1' | psql # to hopefully get a useful error message 33 | false 34 | fi 35 | sleep 2 36 | done 37 | 38 | echo 'SELECT PostGIS_Version()' | psql 39 | [ "$(echo 'SELECT ST_X(ST_Point(0,0))' | psql)" = 0 ] 40 | 41 | 42 | ## test address_standardizer extension 43 | echo 'CREATE EXTENSION address_standardizer;' | psql 44 | response=$(echo $'SELECT zip FROM parse_address(\'1 Devonshire Place, Boston, MA 02109-1234\') AS a;' | psql) 45 | if [ $response = 02109 ]; then 46 | echo "address_standardizer extension installed and works!" 47 | else 48 | echo "address_standardizer extension test failed, returned response is $response" 49 | exit 1 50 | fi 51 | 52 | -------------------------------------------------------------------------------- /update-postgis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Perform all actions as $POSTGRES_USER 6 | export PGUSER="$POSTGRES_USER" 7 | 8 | POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" 9 | 10 | # Load PostGIS into both template_database and $POSTGRES_DB 11 | for DB in template_postgis "$POSTGRES_DB" "${@}"; do 12 | echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" 13 | psql --dbname="$DB" -c " 14 | -- Upgrade PostGIS (includes raster) 15 | CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; 16 | ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; 17 | 18 | -- Upgrade Topology 19 | CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; 20 | ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; 21 | 22 | -- Install Tiger dependencies in case not already installed 23 | CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; 24 | -- Upgrade US Tiger Geocoder 25 | CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; 26 | ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; 27 | " 28 | done 29 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Derived from https://github.com/docker-library/postgres/blob/master/update.sh 3 | set -Eeuo pipefail 4 | 5 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 6 | 7 | versions=( "$@" ) 8 | if [ ${#versions[@]} -eq 0 ]; then 9 | versions=( */Dockerfile ) 10 | fi 11 | versions=( "${versions[@]%/Dockerfile}" ) 12 | 13 | for optimized in debian alpine test; do 14 | rm -f _dockerlists_${optimized}.md 15 | echo " " > _dockerlists_${optimized}.md 16 | echo "| DockerHub image | Dockerfile | OS | Postgres | PostGIS |" >> _dockerlists_${optimized}.md 17 | echo "| --------------- | ---------- | -- | -------- | ------- |" >> _dockerlists_${optimized}.md 18 | done 19 | 20 | autogenerated='NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY.' 21 | 22 | dockerhublink="https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=" 23 | githubrepolink="https://github.com/postgis/docker-postgis/blob/master" 24 | 25 | # sort version numbers with highest last (so it goes first in .travis.yml) 26 | IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -V) ); unset IFS 27 | 28 | defaultAlpinenSuite='3.22' 29 | defaultDebianSuite='bullseye-slim' 30 | declare -A debianSuite=( 31 | # https://github.com/docker-library/postgres/issues/582 32 | [11]='bullseye-slim' 33 | [12]='bullseye-slim' 34 | [13]='bullseye-slim' 35 | [14]='bullseye-slim' 36 | [15]='bullseye-slim' 37 | [16]='bullseye-slim' 38 | [17]='bullseye-slim' 39 | [18]='bullseye-slim' 40 | ) 41 | 42 | defaultPostgisDebPkgNameVersionSuffix='3' 43 | declare -A postgisDebPkgNameVersionSuffixes=( 44 | [3.0]='3' 45 | [3.1]='3' 46 | [3.2]='3' 47 | [3.3]='3' 48 | [3.4]='3' 49 | [3.5]='3' 50 | [3.6]='3' 51 | ) 52 | 53 | packagesBase='http://apt.postgresql.org/pub/repos/apt/dists/' 54 | 55 | cgalGitHash="$(git ls-remote https://github.com/CGAL/cgal.git heads/master | awk '{ print $1}')" 56 | sfcgalGitHash="$(git ls-remote https://gitlab.com/SFCGAL/SFCGAL.git heads/master | awk '{ print $1}')" 57 | projGitHash="$(git ls-remote https://github.com/OSGeo/PROJ.git heads/master | awk '{ print $1}')" 58 | gdalGitHash="$(git ls-remote https://github.com/OSGeo/gdal.git refs/heads/master | grep '\srefs/heads/master' | awk '{ print $1}')" 59 | geosGitHash="$(git ls-remote https://github.com/libgeos/geos.git heads/main | awk '{ print $1}')" 60 | postgisGitHash="$(git ls-remote https://github.com/postgis/postgis.git heads/master | awk '{ print $1}')" 61 | 62 | #------------------------------------------- 63 | # Correct version sorting 64 | function version_reverse_sort() { 65 | # This function sorts version numbers in reverse order, 66 | # ensuring that versions without pre-release tags (e.g., "3.4.0") 67 | # are ranked higher than those with pre-release tags (e.g., "3.4.0rc4"). 68 | # It adds a ".9991" suffix to versions without pre-release tags, 69 | # sorts them with `sort -Vr`, and then removes the ".9991" suffix. 70 | sed -r "s/([0-9]+\.[0-9]+\.[0-9]+$)/\1\.9991/" | sort -Vr | sed s/\.9991$// 71 | } 72 | 73 | api_preference="github" 74 | function fetch_postgis_versions() { 75 | # get all postgis versions from github 76 | local REPO="postgis/postgis" 77 | local PER_PAGE=100 # You can ask for up to 100 results per page 78 | local page=1 79 | postgis_all_v3_versions="" 80 | 81 | while true; do 82 | local response 83 | if [ "$api_preference" == "github" ]; then 84 | response=$(curl --silent "https://api.github.com/repos/$REPO/tags?per_page=$PER_PAGE&page=$page") || { 85 | echo "Failed to fetch postgis_versions from api.github.com/repos/$REPO/tags" 86 | return 1 87 | } 88 | elif [ "$api_preference" == "osgeo" ]; then 89 | response=$(curl --silent "https://git.osgeo.org/gitea/api/v1/repos/${REPO}/tags?page=$page&limit=$PER_PAGE") || { 90 | echo "Failed to fetch postgis_versions from git.osgeo.org/gitea/api/v1/repos/${REPO}/tags" 91 | return 1 92 | } 93 | fi 94 | 95 | # Check for rate limit exceeded error - related to api.github.com 96 | if echo "$response" | grep -q "API rate limit exceeded"; then 97 | echo "Error: API rate limit exceeded!" 98 | echo "$response" 99 | exit 1 100 | fi 101 | 102 | # Extract tag names from the JSON response 103 | local tags 104 | tags=$(echo "$response" | grep -Po '"name":\s*"\K[^"]+' || true) 105 | local count 106 | count=$(echo "$tags" | sed '/^$/d' | wc -l) 107 | 108 | if ((count == 0)); then 109 | break 110 | fi 111 | 112 | if ((page > 12)); then 113 | echo "Too many pages: ${page} - exiting; unexpected and something is wrong!" 114 | exit 1 115 | fi 116 | 117 | postgis_all_v3_versions+=" $tags" 118 | 119 | ((page++)) 120 | done 121 | } 122 | 123 | fetch_postgis_versions || { 124 | echo "Error fetching postgis versions! Maybe network or server error!" 125 | exit 1 126 | } 127 | 128 | # Keep 3.* versions only 129 | postgis_all_v3_versions=$(echo "$postgis_all_v3_versions" | sed '/^$/d' | grep '^3\.' | version_reverse_sort) 130 | postgis_all_v3_versions_array_string=$(echo "$postgis_all_v3_versions" | tr '\n' ' ') 131 | echo "postgis_all_v3_versions_array_string = ${postgis_all_v3_versions_array_string}" 132 | echo " " 133 | 134 | #------------------------------------------- 135 | 136 | declare -A suitePackageList=() suiteArches=() 137 | for version in "${versions[@]}"; do 138 | IFS=- read postgresVersion postgisVersion <<< "$version" 139 | 140 | echo " " 141 | echo "---- generate Dockerfile for $version ----" 142 | echo "postgresVersion=$postgresVersion" 143 | echo "postgisVersion=$postgisVersion" 144 | 145 | if [ "2.5" == "$postgisVersion" ]; then 146 | # posgis 2.5 only in the stretch ; no bullseye version 147 | tag='stretch-slim' 148 | else 149 | tag="${debianSuite[$postgresVersion]:-$defaultDebianSuite}" 150 | fi 151 | suite="${tag%%-slim}" 152 | 153 | if [ -z "${suitePackageList["$suite"]:+isset}" ]; then 154 | suitePackageList["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/main/binary-amd64/Packages.bz2" | bunzip2)" 155 | fi 156 | if [ -z "${suiteArches["$suite"]:+isset}" ]; then 157 | suiteArches["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/Release" | awk -F ':[[:space:]]+' '$1 == "Architectures" { gsub(/[[:space:]]+/, "|", $2); print $2 }')" 158 | fi 159 | 160 | postgresVersionMain="$(echo "$postgresVersion" | awk -F 'alpha|beta|rc' '{print $1}')" 161 | versionList="$(echo "${suitePackageList["$suite"]}"; curl -fsSL "${packagesBase}/${suite}-pgdg/${postgresVersionMain}/binary-amd64/Packages.bz2" | bunzip2)" 162 | fullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "postgresql-'"$postgresVersionMain"'" { print $2; exit }' || true)" 163 | 164 | if [ "$suite" = "bullseye" ]; then 165 | boostVersion="1.74.0" 166 | else 167 | echo "Unknown debian version; stop" 168 | exit 1 169 | fi 170 | 171 | 172 | optimized="" 173 | if [[ "$version" =~ "alpha" || "$version" =~ "beta" || "$version" =~ "rc" || "$version" =~ "master" ]]; 174 | then 175 | optimized="test" 176 | else 177 | optimized="debian" 178 | fi 179 | echo "optimized=$optimized" 180 | 181 | debianPostgisMajMin="" 182 | if [ "master" == "$postgisVersion" ]; then 183 | postgisPackageName="" 184 | postgisFullVersion="$postgisVersion" 185 | postgisMajor="" 186 | postgisDocSrc="development: postgis, geos, proj, gdal" 187 | else 188 | postgisMajMin="$( echo "${postgisVersion}" | cut -d. -f1 ).$( echo "${postgisVersion}" | cut -d. -f2 )" 189 | echo "postgisMajMin=${postgisMajMin}" 190 | 191 | postgisPackageName="postgresql-${postgresVersionMain}-postgis-${postgisDebPkgNameVersionSuffixes[${postgisMajMin}]}" 192 | postgisFullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"$postgisPackageName"'" { print $2; exit }' || true)" 193 | echo "postgisPackageName=${postgisPackageName}" 194 | echo "postgisFullVersion=${postgisFullVersion}" 195 | 196 | debianPostgisMajMin="$( echo "${postgisFullVersion}" | cut -d. -f1 ).$( echo "${postgisFullVersion}" | cut -d. -f2 )" 197 | 198 | if [ "$debianPostgisMajMin" == "$postgisMajMin" ]; then 199 | echo "debian postgis version is OK " 200 | postgisMajor="${postgisDebPkgNameVersionSuffixes[${postgisMajMin}]}" 201 | postgisDocSrc="${postgisFullVersion%%+*}" 202 | else 203 | echo "debian postgis is not updated, different .. " 204 | postgisFullVersion="" 205 | postgisMajor="" 206 | postgisDocSrc="" 207 | fi 208 | fi 209 | 210 | if [ -z "$postgisFullVersion" ] 211 | then 212 | echo "SKIP debian version"; 213 | # debain version not found; 214 | echo " # placeholder Dockerfile" > "$version/Dockerfile" 215 | echo " # Debian version of postgis $postgisFullVersion is not detected!">> "$version/Dockerfile" 216 | echo " # This is an autogenerated message of ./update.sh " >> "$version/Dockerfile" 217 | rm -f "$version/*.sh" 218 | rm -f "$version/*.md" 219 | # detect the exact Postgis version - for the alpine version 220 | # check the latest released 3.x version (so not alpha/beta/rc) 221 | _postgisMinor=$(echo "$postgisMajMin" | cut -d. -f2) 222 | postgisFullVersion=$(echo "$postgis_all_v3_versions" | grep "^3\.${_postgisMinor}\." | grep -v '[a-zA-Z]' | version_reverse_sort | head -n 1 || true) 223 | # Check if the result is empty 224 | if [[ -z "${postgisFullVersion}" ]]; then 225 | # If empty, run the command again without excluding pre-releases (alpha/beta/rc) 226 | postgisFullVersion=$(echo "$postgis_all_v3_versions" | grep "^3\.${_postgisMinor}\." | version_reverse_sort | head -n 1 || true) 227 | fi 228 | postgisDocSrc=$postgisFullVersion 229 | echo "!!!!! postgisFullVersion = ${postgisFullVersion}"; 230 | else 231 | ( 232 | set -x 233 | cp -p initdb-postgis.sh update-postgis.sh "$version/" 234 | if [ "master" == "$postgisVersion" ]; then 235 | cat Dockerfile.master.template > "$version/Dockerfile" 236 | else 237 | cat Dockerfile.template > "$version/Dockerfile" 238 | fi 239 | sed -i 's/%%TXT_AUTOGENERATED%%/'"$autogenerated"'/g; s/%%PG_MAJOR%%/'$postgresVersion'/g; s/%%POSTGIS_MAJOR%%/'$postgisMajor'/g; s/%%POSTGIS_VERSION%%/'$postgisFullVersion'/g; s/%%POSTGIS_GIT_HASH%%/'$postgisGitHash'/g; s/%%CGAL_GIT_HASH%%/'$cgalGitHash'/g; s/%%SFCGAL_GIT_HASH%%/'$sfcgalGitHash'/g; s/%%PROJ_GIT_HASH%%/'$projGitHash'/g; s/%%GDAL_GIT_HASH%%/'$gdalGitHash'/g; s/%%GEOS_GIT_HASH%%/'$geosGitHash'/g; s/%%BOOST_VERSION%%/'"$boostVersion"'/g; s/%%DEBIAN_VERSION%%/'"$suite"'/g;' "$version/Dockerfile" 240 | 241 | echo "| [postgis/postgis:${version}](${dockerhublink}${version}) | [Dockerfile](${githubrepolink}/${version}/Dockerfile) | debian:${suite} | ${postgresVersion} | ${postgisDocSrc} |" >> _dockerlists_${optimized}.md 242 | ) 243 | fi 244 | 245 | if [ "master" == "$postgisVersion" ]; then 246 | srcVersion="" 247 | srcSha256="" 248 | elif [ -d "$version/alpine" ]; then 249 | # For Alpine, get the latest release in the same minor version series 250 | _postgisMajor=$(echo "$postgisMajMin" | cut -d. -f1) 251 | _postgisMinor=$(echo "$postgisMajMin" | cut -d. -f2) 252 | 253 | # Find the latest non-preview release for this minor version 254 | srcVersion=$(echo "$postgis_all_v3_versions_array_string" | tr ' ' '\n' | grep "^${_postgisMajor}\.${_postgisMinor}\." | grep -v '[a-zA-Z]' | head -n 1 || true) 255 | 256 | # If no stable release found, fall back to the debian version 257 | if [ -z "$srcVersion" ]; then 258 | echo " No stable release found for ${_postgisMajor}.${_postgisMinor}. Falling back ..." 259 | # For alpha/beta/rc versions, use the version from directory name 260 | if [[ "$postgisVersion" =~ alpha|beta|rc ]]; then 261 | srcVersion="$postgisVersion" 262 | else 263 | srcVersion="${postgisFullVersion%%+*}" 264 | fi 265 | fi 266 | 267 | srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/$srcVersion.tar.gz" | sha256sum | awk '{ print $1 }')" 268 | echo "Selected PostGIS version for Alpine: ${srcVersion}" 269 | postgisDocSrc=$srcVersion 270 | else 271 | srcVersion="${postgisFullVersion%%+*}" 272 | srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/$srcVersion.tar.gz" | sha256sum | awk '{ print $1 }')" 273 | postgisDocSrc=$srcVersion 274 | fi 275 | 276 | for variant in alpine; do 277 | if [ ! -d "$version/$variant" ]; then 278 | continue 279 | fi 280 | ( 281 | set -x 282 | if [ "$optimized" != "test" ]; then 283 | optimized="alpine" 284 | fi 285 | cp -p Dockerfile.alpine.template initdb-postgis.sh update-postgis.sh "$version/$variant/" 286 | mv "$version/$variant/Dockerfile.alpine.template" "$version/$variant/Dockerfile" 287 | sed -i 's/%%TXT_AUTOGENERATED%%/'"$autogenerated"'/g; s/%%PG_MAJOR%%/'"$postgresVersion"'/g; s/%%POSTGIS_VERSION%%/'"$srcVersion"'/g; s/%%POSTGIS_SHA256%%/'"$srcSha256"'/g' "$version/$variant/Dockerfile" 288 | 289 | echo "| [postgis/postgis:${version}-${variant}](${dockerhublink}${version}-${variant}) | [Dockerfile](${githubrepolink}/${version}/${variant}/Dockerfile) | alpine:${defaultAlpinenSuite} | ${postgresVersion} | ${postgisDocSrc} |" >> _dockerlists_${optimized}.md 290 | ) 291 | done 292 | done 293 | 294 | echo "|-------------------------|" 295 | echo "|- Generated images -|" 296 | echo "|-------------------------|" 297 | 298 | for optimized in debian alpine test; do 299 | echo " " 300 | echo "---- ${optimized} ----" 301 | cat _dockerlists_${optimized}.md 302 | done 303 | 304 | echo " " 305 | echo "Postprocessing todo:" 306 | echo "- add the new versions to README.md ( manually )" 307 | ls -la _dockerlists_*.md 308 | echo " " 309 | echo " - done - " 310 | --------------------------------------------------------------------------------