From 62d2c576d901ac8d8cf30d46eaf2b6efb299a1ba Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Mon, 10 Feb 2020 04:08:56 +0000 Subject: [PATCH 1/7] - Updated dockerfile templates to reflect new maintainer labeling, debian package installation, and alpine build process - Updated Makefile and postgis-config.sh for tests to change mdillon docker repo to postgis docker repo - Updated update.sh script to use more modern parsing of debian packages to accommodate multiple debian versions in a similar way to how the postgres image built as part of docker-library accomplishes it --- .travis.yml | 20 ++++---- Dockerfile.alpine.template | 23 +++++---- Dockerfile.template | 4 +- Makefile | 4 +- test/postgis-config.sh | 4 +- update.sh | 95 ++++++++++++++++++++++---------------- 6 files changed, 81 insertions(+), 69 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7104d3c5f..5c5ded516 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,18 +5,18 @@ services: docker dist: xenial env: - - VERSION=9.4-2.5 - - VERSION=9.4-2.5 VARIANT=alpine - - VERSION=9.5-2.5 - - VERSION=9.5-2.5 VARIANT=alpine - - VERSION=9.6-2.5 - - VERSION=9.6-2.5 VARIANT=alpine - - VERSION=10-2.5 - - VERSION=10-2.5 VARIANT=alpine - - VERSION=11-2.5 - - VERSION=11-2.5 VARIANT=alpine - VERSION=12-2.5 - VERSION=12-2.5 VARIANT=alpine + - VERSION=11-2.5 + - VERSION=11-2.5 VARIANT=alpine + - VERSION=10-2.5 + - VERSION=10-2.5 VARIANT=alpine + - VERSION=9.6-2.5 + - VERSION=9.6-2.5 VARIANT=alpine + - VERSION=9.5-2.5 + - VERSION=9.5-2.5 VARIANT=alpine + - VERSION=9.4-2.5 + - VERSION=9.4-2.5 VARIANT=alpine install: - git clone https://github.com/docker-library/official-images.git ~/official-images diff --git a/Dockerfile.alpine.template b/Dockerfile.alpine.template index d3e5f34f0..c7685fd3e 100644 --- a/Dockerfile.alpine.template +++ b/Dockerfile.alpine.template @@ -1,5 +1,6 @@ FROM postgres:%%PG_MAJOR%%-alpine -MAINTAINER Régis Belson + +LABEL maintainer="PostGIS Project - https://postgis.net" ENV POSTGIS_VERSION %%POSTGIS_VERSION%% ENV POSTGIS_SHA256 %%POSTGIS_SHA256%% @@ -24,19 +25,19 @@ RUN set -ex \ && apk add --no-cache --virtual .build-deps \ autoconf \ automake \ - g++ \ + file \ json-c-dev \ libtool \ libxml2-dev \ make \ perl \ - \ - && apk add --no-cache --virtual .build-deps-edge \ - --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \ - --repository http://dl-cdn.alpinelinux.org/alpine/edge/main \ + clang-dev \ + g++ \ + gcc \ gdal-dev \ geos-dev \ - proj4-dev \ + llvm9-dev \ + proj-dev \ protobuf-c-dev \ && cd /usr/src/postgis \ && ./autogen.sh \ @@ -48,16 +49,14 @@ RUN set -ex \ && make install \ && apk add --no-cache --virtual .postgis-rundeps \ json-c \ - && apk add --no-cache --virtual .postgis-rundeps-edge \ - --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \ - --repository http://dl-cdn.alpinelinux.org/alpine/edge/main \ geos \ gdal \ - proj4 \ + proj \ + libstdc++ \ protobuf-c \ && cd / \ && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps .build-deps-edge + && apk del .fetch-deps .build-deps COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh COPY ./update-postgis.sh /usr/local/bin diff --git a/Dockerfile.template b/Dockerfile.template index 8f8b6191d..8a77b1196 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,5 +1,6 @@ FROM postgres:%%PG_MAJOR%% -MAINTAINER Mike Dillon + +LABEL maintainer="PostGIS Project - https://postgis.net" ENV POSTGIS_MAJOR %%POSTGIS_MAJOR%% ENV POSTGIS_VERSION %%POSTGIS_VERSION%% @@ -9,7 +10,6 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \ - postgis=$POSTGIS_VERSION \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /docker-entrypoint-initdb.d diff --git a/Makefile b/Makefile index 2a05bbcd6..774f4e42a 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ build: $(VERSIONS) define postgis-version $1: - docker build -t mdillon/postgis:$(shell echo $1 | sed -e 's/-.*//g') $1 - docker build -t mdillon/postgis:$(shell echo $1 | sed -e 's/-.*//g')-alpine $1/alpine + docker build -t postgis/postgis:$(shell echo $1 | sed -e 's/-.*//g') $1 + docker build -t postgis/postgis:$(shell echo $1 | sed -e 's/-.*//g')-alpine $1/alpine endef $(foreach version,$(VERSIONS),$(eval $(call postgis-version,$(version)))) diff --git a/test/postgis-config.sh b/test/postgis-config.sh index 1b11b0339..39027796a 100644 --- a/test/postgis-config.sh +++ b/test/postgis-config.sh @@ -1,5 +1,5 @@ -testAlias[appropriate/postgis]=postgres +testAlias[postgis/postgis]=postgres -imageTests[appropriate/postgis]=' +imageTests[postgis/postgis]=' postgis-basics ' diff --git a/update.sh b/update.sh index 42a164818..d42029e51 100755 --- a/update.sh +++ b/update.sh @@ -1,6 +1,6 @@ #!/bin/bash # Derived from https://github.com/docker-library/postgres/blob/master/update.sh -set -e +set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" @@ -10,51 +10,64 @@ if [ ${#versions[@]} -eq 0 ]; then fi versions=( "${versions[@]%/Dockerfile}" ) -packagesUrlJessie='http://apt.postgresql.org/pub/repos/apt/dists/jessie-pgdg/main/binary-amd64/Packages' -packagesJessie="$(echo "$packagesUrlJessie" | sed -r 's/[^a-zA-Z.-]+/-/g')" -curl -sSL "${packagesUrlJessie}.bz2" | bunzip2 > "$packagesJessie" +# sort version numbers with highest last (so it goes first in .travis.yml) +IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -V) ); unset IFS -packagesUrlStretch='http://apt.postgresql.org/pub/repos/apt/dists/stretch-pgdg/main/binary-amd64/Packages' -packagesStretch="$(echo "$packagesUrlStretch" | sed -r 's/[^a-zA-Z.-]+/-/g')" -curl -sSL "${packagesUrlStretch}.bz2" | bunzip2 > "$packagesStretch" +defaultDebianSuite='buster-slim' +declare -A debianSuite=( + # https://github.com/docker-library/postgres/issues/582 + [9.4]='stretch-slim' + [9.5]='stretch-slim' + [9.6]='stretch-slim' + [10]='stretch-slim' + [11]='stretch-slim' +) +defaultAlpineVersion='3.11' +declare -A alpineVersion=( + #[9.6]='3.5' +) +packagesBase='http://apt.postgresql.org/pub/repos/apt/dists/' + +declare -A suitePackageList=() suiteArches=() travisEnv= for version in "${versions[@]}"; do - IFS=- read pg_major postgis_major <<< "$version" - if [[ $pg_major = 9* ]]; then - packages="$packagesStretch" - else - packages="$packagesStretch" - fi - - fullVersion="$(grep -m1 -A10 "^Package: postgresql-$pg_major-postgis-$postgis_major\$" "$packages" | grep -m1 '^Version: ' | cut -d' ' -f2)" - [ -z "$fullVersion" ] && { echo >&2 "Unable to find package for PostGIS $postgis_major on Postgres $pg_major"; exit 1; } - ( - set -x - cp Dockerfile.template initdb-postgis.sh update-postgis.sh README.md "$version/" - mv "$version/Dockerfile.template" "$version/Dockerfile" - sed -i 's/%%PG_MAJOR%%/'$pg_major'/g; s/%%POSTGIS_MAJOR%%/'$postgis_major'/g; s/%%POSTGIS_VERSION%%/'$fullVersion'/g' "$version/Dockerfile" - ) - - srcVersion="${fullVersion%%+*}" - srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/$srcVersion.tar.gz" | sha256sum | awk '{ print $1 }')" - for variant in alpine; do - if [ ! -d "$version/$variant" ]; then - continue - fi - ( - set -x - cp Dockerfile.alpine.template initdb-postgis.sh update-postgis.sh "$version/$variant/" - mv "$version/$variant/Dockerfile.alpine.template" "$version/$variant/Dockerfile" - sed -i 's/%%PG_MAJOR%%/'"$pg_major"'/g; s/%%POSTGIS_VERSION%%/'"$srcVersion"'/g; s/%%POSTGIS_SHA256%%/'"$srcSha256"'/g' "$version/$variant/Dockerfile" - ) - travisEnv="\n - VERSION=$version VARIANT=$variant$travisEnv" - done - - travisEnv='\n - VERSION='"$version$travisEnv" + IFS=- read postgresVersion postgisVersion <<< "$version" + + tag="${debianSuite[$postgresVersion]:-$defaultDebianSuite}" + suite="${tag%%-slim}" + + if [ -z "${suitePackageList["$suite"]:+isset}" ]; then + suitePackageList["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/main/binary-amd64/Packages.bz2" | bunzip2)" + fi + if [ -z "${suiteArches["$suite"]:+isset}" ]; then + suiteArches["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/Release" | awk -F ':[[:space:]]+' '$1 == "Architectures" { gsub(/[[:space:]]+/, "|", $2); print $2 }')" + fi + + versionList="$(echo "${suitePackageList["$suite"]}"; curl -fsSL "${packagesBase}/${suite}-pgdg/${postgresVersion}/binary-amd64/Packages.bz2" | bunzip2)" + fullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "postgresql-'"$postgresVersion"'" { print $2; exit }' || true)" + majorVersion="${postgresVersion%%.*}" + + postgisPackageName="postgresql-${postgresVersion}-postgis-${postgisVersion}" + postgisFullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"$postgisPackageName"'" { print $2; exit }' || true)" + + srcVersion="${postgisFullVersion%%+*}" + srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/$srcVersion.tar.gz" | sha256sum | awk '{ print $1 }')" + for variant in alpine; do + if [ ! -d "$version/$variant" ]; then + continue + fi + ( + set -x + cp Dockerfile.alpine.template initdb-postgis.sh update-postgis.sh "$version/$variant/" + mv "$version/$variant/Dockerfile.alpine.template" "$version/$variant/Dockerfile" + sed -i 's/%%PG_MAJOR%%/'"$postgresVersion"'/g; s/%%POSTGIS_VERSION%%/'"$srcVersion"'/g; s/%%POSTGIS_SHA256%%/'"$srcSha256"'/g' "$version/$variant/Dockerfile" + ) + travisEnv="\n - VERSION=$version VARIANT=$variant$travisEnv" + done + travisEnv='\n - VERSION='"$version$travisEnv" + done travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)" echo "$travis" > .travis.yml -rm "$packagesJessie" -rm "$packagesStretch" From 29e2c7514d2fa724f788b11ea559e7d8365f2fa8 Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Mon, 10 Feb 2020 18:51:02 +0000 Subject: [PATCH 2/7] Removing PostgreSQL 9.4 builds as the EOL for 9.4 release is 2020-02-13 --- .travis.yml | 2 -- 9.4-2.5/Dockerfile | 18 ---------- 9.4-2.5/README.md | 51 -------------------------- 9.4-2.5/alpine/Dockerfile | 62 -------------------------------- 9.4-2.5/alpine/initdb-postgis.sh | 23 ------------ 9.4-2.5/alpine/update-postgis.sh | 28 --------------- 9.4-2.5/initdb-postgis.sh | 23 ------------ 9.4-2.5/update-postgis.sh | 28 --------------- 8 files changed, 235 deletions(-) delete mode 100644 9.4-2.5/Dockerfile delete mode 100644 9.4-2.5/README.md delete mode 100644 9.4-2.5/alpine/Dockerfile delete mode 100644 9.4-2.5/alpine/initdb-postgis.sh delete mode 100755 9.4-2.5/alpine/update-postgis.sh delete mode 100644 9.4-2.5/initdb-postgis.sh delete mode 100755 9.4-2.5/update-postgis.sh diff --git a/.travis.yml b/.travis.yml index 5c5ded516..75003ebeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,6 @@ env: - VERSION=9.6-2.5 VARIANT=alpine - VERSION=9.5-2.5 - VERSION=9.5-2.5 VARIANT=alpine - - VERSION=9.4-2.5 - - VERSION=9.4-2.5 VARIANT=alpine install: - git clone https://github.com/docker-library/official-images.git ~/official-images diff --git a/9.4-2.5/Dockerfile b/9.4-2.5/Dockerfile deleted file mode 100644 index 123334ad6..000000000 --- a/9.4-2.5/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM postgres:9.4 - -LABEL maintainer="PostGIS Project - https://postgis.net" - -ENV POSTGIS_MAJOR 2.5 -ENV POSTGIS_VERSION 2.5.3+dfsg-3.pgdg90+1 - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/9.4-2.5/README.md b/9.4-2.5/README.md deleted file mode 100644 index 1a4876919..000000000 --- a/9.4-2.5/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# postgis/postgis - -[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.4-9.6), Postgres 10, Postgres 11, and Postgres 12. - -This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: - -* `postgis` -* `postgis_topology` -* `fuzzystrmatch` -* `postgis_tiger_geocoder` - -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`. - -## Usage - -In order to run a basic container capable of serving a PostGIS-enabled database, start a container as follows: - - docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis - -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/). - -Once you have started a database container, you can then connect to the database as follows: - - docker run -it --link some-postgis:postgres --rm postgres \ - sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres' - -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. - -## Known Issues / Errors - -When You encouter errors due to PostGIS update `OperationalError: could not access file "$libdir/postgis-X.X`, run: - -`docker exec some-postgis update-postgis.sh` - -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: - -``` -Updating PostGIS extensions template_postgis to X.X.X -NOTICE: version "X.X.X" of extension "postgis" is already installed -NOTICE: version "X.X.X" of extension "postgis_topology" is already installed -NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed -ALTER EXTENSION -Updating PostGIS extensions docker to X.X.X -NOTICE: version "X.X.X" of extension "postgis" is already installed -NOTICE: version "X.X.X" of extension "postgis_topology" is already installed -NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed -ALTER EXTENSION -``` - diff --git a/9.4-2.5/alpine/Dockerfile b/9.4-2.5/alpine/Dockerfile deleted file mode 100644 index b244327af..000000000 --- a/9.4-2.5/alpine/Dockerfile +++ /dev/null @@ -1,62 +0,0 @@ -FROM postgres:9.4-alpine - -LABEL maintainer="PostGIS Project - https://postgis.net" - -ENV POSTGIS_VERSION 2.5.3 -ENV POSTGIS_SHA256 402323c83d97f3859bc9083345dd687f933c261efe0830e1262c20c12671f794 - -RUN set -ex \ - \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/$POSTGIS_VERSION.tar.gz" \ - && echo "$POSTGIS_SHA256 *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - autoconf \ - automake \ - file \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - perl \ - clang-dev \ - g++ \ - gcc \ - gdal-dev \ - geos-dev \ - llvm9-dev \ - proj-dev \ - protobuf-c-dev \ - && cd /usr/src/postgis \ - && ./autogen.sh \ -# configure options taken from: -# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie - && ./configure \ -# --with-gui \ - && make \ - && make install \ - && apk add --no-cache --virtual .postgis-rundeps \ - json-c \ - geos \ - gdal \ - proj \ - libstdc++ \ - protobuf-c \ - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/9.4-2.5/alpine/initdb-postgis.sh b/9.4-2.5/alpine/initdb-postgis.sh deleted file mode 100644 index 430128855..000000000 --- a/9.4-2.5/alpine/initdb-postgis.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis; -UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/9.4-2.5/alpine/update-postgis.sh b/9.4-2.5/alpine/update-postgis.sh deleted file mode 100755 index f98abd261..000000000 --- a/9.4-2.5/alpine/update-postgis.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB" "${@}"; do - echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" - psql --dbname="$DB" -c " - -- Upgrade PostGIS (includes raster) - CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; - ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; - - -- Upgrade Topology - CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; - ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; - - -- Install Tiger dependencies in case not already installed - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - -- Upgrade US Tiger Geocoder - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; - ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; - " -done diff --git a/9.4-2.5/initdb-postgis.sh b/9.4-2.5/initdb-postgis.sh deleted file mode 100644 index 430128855..000000000 --- a/9.4-2.5/initdb-postgis.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis; -UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/9.4-2.5/update-postgis.sh b/9.4-2.5/update-postgis.sh deleted file mode 100755 index f98abd261..000000000 --- a/9.4-2.5/update-postgis.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB" "${@}"; do - echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" - psql --dbname="$DB" -c " - -- Upgrade PostGIS (includes raster) - CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; - ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; - - -- Upgrade Topology - CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; - ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; - - -- Install Tiger dependencies in case not already installed - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - -- Upgrade US Tiger Geocoder - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; - ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; - " -done From e4bce9700f3805a4ed00dc057bbf40b32cbaf8c0 Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Mon, 10 Feb 2020 22:35:28 +0000 Subject: [PATCH 3/7] - Updated README.md to reflect support for PostgreSQL 9.5, 9.6, 10, 11, and 12 (dropping EOL 9.4) - Added Dockerfile template processing for debian images --- 10-2.5/README.md | 2 +- 11-2.5/README.md | 2 +- 12-2.5/README.md | 2 +- 9.5-2.5/README.md | 2 +- 9.6-2.5/README.md | 2 +- README.md | 2 +- update.sh | 6 ++++++ 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/10-2.5/README.md b/10-2.5/README.md index 1a4876919..502b653e6 100644 --- a/10-2.5/README.md +++ b/10-2.5/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.4-9.6), Postgres 10, Postgres 11, and Postgres 12. +The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: diff --git a/11-2.5/README.md b/11-2.5/README.md index 1a4876919..502b653e6 100644 --- a/11-2.5/README.md +++ b/11-2.5/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.4-9.6), Postgres 10, Postgres 11, and Postgres 12. +The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: diff --git a/12-2.5/README.md b/12-2.5/README.md index 1a4876919..502b653e6 100644 --- a/12-2.5/README.md +++ b/12-2.5/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.4-9.6), Postgres 10, Postgres 11, and Postgres 12. +The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: diff --git a/9.5-2.5/README.md b/9.5-2.5/README.md index 1a4876919..502b653e6 100644 --- a/9.5-2.5/README.md +++ b/9.5-2.5/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.4-9.6), Postgres 10, Postgres 11, and Postgres 12. +The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: diff --git a/9.6-2.5/README.md b/9.6-2.5/README.md index 1a4876919..502b653e6 100644 --- a/9.6-2.5/README.md +++ b/9.6-2.5/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.4-9.6), Postgres 10, Postgres 11, and Postgres 12. +The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: diff --git a/README.md b/README.md index 1a4876919..502b653e6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.4-9.6), Postgres 10, Postgres 11, and Postgres 12. +The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: diff --git a/update.sh b/update.sh index d42029e51..322b155b0 100755 --- a/update.sh +++ b/update.sh @@ -50,6 +50,12 @@ for version in "${versions[@]}"; do postgisPackageName="postgresql-${postgresVersion}-postgis-${postgisVersion}" postgisFullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"$postgisPackageName"'" { print $2; exit }' || true)" + ( + set -x + cp Dockerfile.template initdb-postgis.sh update-postgis.sh README.md "$version/" + mv "$version/Dockerfile.template" "$version/Dockerfile" + sed -i 's/%%PG_MAJOR%%/'$postgresVersion'/g; s/%%POSTGIS_MAJOR%%/'$postgisVersion'/g; s/%%POSTGIS_VERSION%%/'$postgisFullVersion'/g' "$version/Dockerfile" + ) srcVersion="${postgisFullVersion%%+*}" srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/$srcVersion.tar.gz" | sha256sum | awk '{ print $1 }')" From c22881b5df8b8167c819852824505c482c0a0199 Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Tue, 11 Feb 2020 01:36:33 +0000 Subject: [PATCH 4/7] - Updated README.md to change gitter.im reference from appropriate community to PostGIS community --- 10-2.5/README.md | 2 +- 11-2.5/README.md | 2 +- 12-2.5/README.md | 2 +- 9.5-2.5/README.md | 2 +- 9.6-2.5/README.md | 2 +- README.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/10-2.5/README.md b/10-2.5/README.md index 502b653e6..1f20ad8dd 100644 --- a/10-2.5/README.md +++ b/10-2.5/README.md @@ -1,6 +1,6 @@ # postgis/postgis -[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![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) The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. diff --git a/11-2.5/README.md b/11-2.5/README.md index 502b653e6..1f20ad8dd 100644 --- a/11-2.5/README.md +++ b/11-2.5/README.md @@ -1,6 +1,6 @@ # postgis/postgis -[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![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) The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. diff --git a/12-2.5/README.md b/12-2.5/README.md index 502b653e6..1f20ad8dd 100644 --- a/12-2.5/README.md +++ b/12-2.5/README.md @@ -1,6 +1,6 @@ # postgis/postgis -[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![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) The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. diff --git a/9.5-2.5/README.md b/9.5-2.5/README.md index 502b653e6..1f20ad8dd 100644 --- a/9.5-2.5/README.md +++ b/9.5-2.5/README.md @@ -1,6 +1,6 @@ # postgis/postgis -[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![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) The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. diff --git a/9.6-2.5/README.md b/9.6-2.5/README.md index 502b653e6..1f20ad8dd 100644 --- a/9.6-2.5/README.md +++ b/9.6-2.5/README.md @@ -1,6 +1,6 @@ # postgis/postgis -[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![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) The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. diff --git a/README.md b/README.md index 502b653e6..1f20ad8dd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # postgis/postgis -[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![Join the chat at https://gitter.im/appropriate/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/appropriate/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![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) The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. From 6d6cd1f4823377f8eb54c7494b24bcf0ef06305b Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Tue, 11 Feb 2020 02:24:21 +0000 Subject: [PATCH 5/7] - Modified update.sh to preserve owner, mode, and timestamp when copying templates --- update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 322b155b0..1aec7a405 100755 --- a/update.sh +++ b/update.sh @@ -52,7 +52,7 @@ for version in "${versions[@]}"; do postgisFullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"$postgisPackageName"'" { print $2; exit }' || true)" ( set -x - cp Dockerfile.template initdb-postgis.sh update-postgis.sh README.md "$version/" + cp -p Dockerfile.template initdb-postgis.sh update-postgis.sh README.md "$version/" mv "$version/Dockerfile.template" "$version/Dockerfile" sed -i 's/%%PG_MAJOR%%/'$postgresVersion'/g; s/%%POSTGIS_MAJOR%%/'$postgisVersion'/g; s/%%POSTGIS_VERSION%%/'$postgisFullVersion'/g' "$version/Dockerfile" ) @@ -65,7 +65,7 @@ for version in "${versions[@]}"; do fi ( set -x - cp Dockerfile.alpine.template initdb-postgis.sh update-postgis.sh "$version/$variant/" + cp -p Dockerfile.alpine.template initdb-postgis.sh update-postgis.sh "$version/$variant/" mv "$version/$variant/Dockerfile.alpine.template" "$version/$variant/Dockerfile" sed -i 's/%%PG_MAJOR%%/'"$postgresVersion"'/g; s/%%POSTGIS_VERSION%%/'"$srcVersion"'/g; s/%%POSTGIS_SHA256%%/'"$srcSha256"'/g' "$version/$variant/Dockerfile" ) From a3d3b1011700eac10df9471e0d3be1a592c6ce25 Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Tue, 11 Feb 2020 22:59:07 +0000 Subject: [PATCH 6/7] - Changes to update.sh to use predefined debian package names suffixes in an associate array since version 3.0.0 package only contains the major version and not the minor - Changes to Makefile to use tags formed from the version-specific directory names - Added overridable variables to Makefile to enable passing in repository and image name from environment variables - Added version-specific directory to create a build for postgres v9.5.x w/ 3.0.x --- .travis.yml | 2 ++ 9.5-3.0/Dockerfile | 18 ++++++++++ 9.5-3.0/README.md | 51 ++++++++++++++++++++++++++ 9.5-3.0/alpine/Dockerfile | 62 ++++++++++++++++++++++++++++++++ 9.5-3.0/alpine/initdb-postgis.sh | 23 ++++++++++++ 9.5-3.0/alpine/update-postgis.sh | 28 +++++++++++++++ 9.5-3.0/initdb-postgis.sh | 23 ++++++++++++ 9.5-3.0/update-postgis.sh | 28 +++++++++++++++ Makefile | 6 ++-- update.sh | 10 ++++-- 10 files changed, 247 insertions(+), 4 deletions(-) create mode 100644 9.5-3.0/Dockerfile create mode 100644 9.5-3.0/README.md create mode 100644 9.5-3.0/alpine/Dockerfile create mode 100644 9.5-3.0/alpine/initdb-postgis.sh create mode 100755 9.5-3.0/alpine/update-postgis.sh create mode 100644 9.5-3.0/initdb-postgis.sh create mode 100755 9.5-3.0/update-postgis.sh diff --git a/.travis.yml b/.travis.yml index 75003ebeb..2860bfd5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ env: - VERSION=10-2.5 VARIANT=alpine - VERSION=9.6-2.5 - VERSION=9.6-2.5 VARIANT=alpine + - VERSION=9.5-3.0 + - VERSION=9.5-3.0 VARIANT=alpine - VERSION=9.5-2.5 - VERSION=9.5-2.5 VARIANT=alpine diff --git a/9.5-3.0/Dockerfile b/9.5-3.0/Dockerfile new file mode 100644 index 000000000..5c11ab557 --- /dev/null +++ b/9.5-3.0/Dockerfile @@ -0,0 +1,18 @@ +FROM postgres:9.5 + +LABEL maintainer="PostGIS Project - https://postgis.net" + +ENV POSTGIS_MAJOR 3 +ENV POSTGIS_VERSION 3.0.0+dfsg-2~exp1.pgdg90+1 + +RUN apt-get update \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh +COPY ./update-postgis.sh /usr/local/bin + diff --git a/9.5-3.0/README.md b/9.5-3.0/README.md new file mode 100644 index 000000000..1f20ad8dd --- /dev/null +++ b/9.5-3.0/README.md @@ -0,0 +1,51 @@ +# postgis/postgis + +[![Build Status](https://travis-ci.org/postgis/docker-postgis.svg)](https://travis-ci.org/postgis/docker-postgis) [![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) + +The `postgis/postgis` image provides a Docker container running Postgres with [PostGIS 2.5](http://postgis.net/) installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for each version of Postgres 9 supported by the base image (9.5-9.6), Postgres 10, Postgres 11, and Postgres 12. + +This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: + +* `postgis` +* `postgis_topology` +* `fuzzystrmatch` +* `postgis_tiger_geocoder` + +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`. + +## Usage + +In order to run a basic container capable of serving a PostGIS-enabled database, start a container as follows: + + docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis + +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/). + +Once you have started a database container, you can then connect to the database as follows: + + docker run -it --link some-postgis:postgres --rm postgres \ + sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres' + +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. + +## Known Issues / Errors + +When You encouter errors due to PostGIS update `OperationalError: could not access file "$libdir/postgis-X.X`, run: + +`docker exec some-postgis update-postgis.sh` + +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: + +``` +Updating PostGIS extensions template_postgis to X.X.X +NOTICE: version "X.X.X" of extension "postgis" is already installed +NOTICE: version "X.X.X" of extension "postgis_topology" is already installed +NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed +ALTER EXTENSION +Updating PostGIS extensions docker to X.X.X +NOTICE: version "X.X.X" of extension "postgis" is already installed +NOTICE: version "X.X.X" of extension "postgis_topology" is already installed +NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed +ALTER EXTENSION +``` + diff --git a/9.5-3.0/alpine/Dockerfile b/9.5-3.0/alpine/Dockerfile new file mode 100644 index 000000000..b26696ced --- /dev/null +++ b/9.5-3.0/alpine/Dockerfile @@ -0,0 +1,62 @@ +FROM postgres:9.5-alpine + +LABEL maintainer="PostGIS Project - https://postgis.net" + +ENV POSTGIS_VERSION 3.0.0 +ENV POSTGIS_SHA256 1c83fb2fc8870d36ed49859c49a12c8c4c8ae8c5c3f912a21a951c5bcc249123 + +RUN set -ex \ + \ + && apk add --no-cache --virtual .fetch-deps \ + ca-certificates \ + openssl \ + tar \ + \ + && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/$POSTGIS_VERSION.tar.gz" \ + && echo "$POSTGIS_SHA256 *postgis.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/src/postgis \ + && tar \ + --extract \ + --file postgis.tar.gz \ + --directory /usr/src/postgis \ + --strip-components 1 \ + && rm postgis.tar.gz \ + \ + && apk add --no-cache --virtual .build-deps \ + autoconf \ + automake \ + file \ + json-c-dev \ + libtool \ + libxml2-dev \ + make \ + perl \ + clang-dev \ + g++ \ + gcc \ + gdal-dev \ + geos-dev \ + llvm9-dev \ + proj-dev \ + protobuf-c-dev \ + && cd /usr/src/postgis \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ +# --with-gui \ + && make \ + && make install \ + && apk add --no-cache --virtual .postgis-rundeps \ + json-c \ + geos \ + gdal \ + proj \ + libstdc++ \ + protobuf-c \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apk del .fetch-deps .build-deps + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/9.5-3.0/alpine/initdb-postgis.sh b/9.5-3.0/alpine/initdb-postgis.sh new file mode 100644 index 000000000..430128855 --- /dev/null +++ b/9.5-3.0/alpine/initdb-postgis.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<- 'EOSQL' +CREATE DATABASE template_postgis; +UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/9.5-3.0/alpine/update-postgis.sh b/9.5-3.0/alpine/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/9.5-3.0/alpine/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/9.5-3.0/initdb-postgis.sh b/9.5-3.0/initdb-postgis.sh new file mode 100644 index 000000000..430128855 --- /dev/null +++ b/9.5-3.0/initdb-postgis.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<- 'EOSQL' +CREATE DATABASE template_postgis; +UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/9.5-3.0/update-postgis.sh b/9.5-3.0/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/9.5-3.0/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/Makefile b/Makefile index 774f4e42a..ab873777f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ VERSIONS = $(foreach df,$(wildcard */Dockerfile),$(df:%/Dockerfile=%)) +REPO_NAME ?= postgis +IMAGE_NAME ?= postgis all: build @@ -6,8 +8,8 @@ build: $(VERSIONS) define postgis-version $1: - docker build -t postgis/postgis:$(shell echo $1 | sed -e 's/-.*//g') $1 - docker build -t postgis/postgis:$(shell echo $1 | sed -e 's/-.*//g')-alpine $1/alpine + docker build -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) $1 + docker build -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine $1/alpine endef $(foreach version,$(VERSIONS),$(eval $(call postgis-version,$(version)))) diff --git a/update.sh b/update.sh index 1aec7a405..595d3a517 100755 --- a/update.sh +++ b/update.sh @@ -27,6 +27,12 @@ declare -A alpineVersion=( #[9.6]='3.5' ) +defaultPostgisDebPkgNameVersionSuffix='3' +declare -A postgisDebPkgNameVersionSuffixes=( + [2.5]='2.5' + [3.0]='3' +) + packagesBase='http://apt.postgresql.org/pub/repos/apt/dists/' declare -A suitePackageList=() suiteArches=() @@ -48,13 +54,13 @@ for version in "${versions[@]}"; do fullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "postgresql-'"$postgresVersion"'" { print $2; exit }' || true)" majorVersion="${postgresVersion%%.*}" - postgisPackageName="postgresql-${postgresVersion}-postgis-${postgisVersion}" + postgisPackageName="postgresql-${postgresVersion}-postgis-${postgisDebPkgNameVersionSuffixes[${postgisVersion}]}" postgisFullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"$postgisPackageName"'" { print $2; exit }' || true)" ( set -x cp -p Dockerfile.template initdb-postgis.sh update-postgis.sh README.md "$version/" mv "$version/Dockerfile.template" "$version/Dockerfile" - sed -i 's/%%PG_MAJOR%%/'$postgresVersion'/g; s/%%POSTGIS_MAJOR%%/'$postgisVersion'/g; s/%%POSTGIS_VERSION%%/'$postgisFullVersion'/g' "$version/Dockerfile" + sed -i 's/%%PG_MAJOR%%/'$postgresVersion'/g; s/%%POSTGIS_MAJOR%%/'${postgisDebPkgNameVersionSuffixes[${postgisVersion}]}'/g; s/%%POSTGIS_VERSION%%/'$postgisFullVersion'/g' "$version/Dockerfile" ) srcVersion="${postgisFullVersion%%+*}" From 9b5994e9f09436cff6e4aade470166b240d5a7db Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Tue, 11 Feb 2020 23:13:52 +0000 Subject: [PATCH 7/7] - Updated travis config to set image to postgis repo instead of appropriate repo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2860bfd5b..f21b9db7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ install: before_script: - env | grep -E "VARIANT|VERSION" | sort - cd "$VERSION/$VARIANT" - - image="appropriate/postgis:$VERSION${VARIANT:+-${VARIANT}}" + - image="postgis/postgis:$VERSION${VARIANT:+-${VARIANT}}" script: - docker build --pull -t "$image" .