From 954715276ca424a5270670b977b5eb675db74849 Mon Sep 17 00:00:00 2001 From: ImreSamu Date: Mon, 25 May 2020 07:17:42 +0200 Subject: [PATCH] add 13-master and update 12-master (#195) --- .travis.yml | 2 + 12-master/Dockerfile | 6 +- 13-master/Dockerfile | 175 ++++++++++++++++++++++++++++++++++++ 13-master/README.md | 51 +++++++++++ 13-master/initdb-postgis.sh | 22 +++++ 13-master/update-postgis.sh | 28 ++++++ 6 files changed, 281 insertions(+), 3 deletions(-) create mode 100644 13-master/Dockerfile create mode 100644 13-master/README.md create mode 100644 13-master/initdb-postgis.sh create mode 100755 13-master/update-postgis.sh diff --git a/.travis.yml b/.travis.yml index 2362cacdf..d83ff8960 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ services: docker dist: xenial env: + - VERSION=13-master - VERSION=12-master - VERSION=12-3.0 - VERSION=12-3.0 VARIANT=alpine @@ -30,6 +31,7 @@ env: jobs: allow_failures: - env: VERSION=12-master + - env: VERSION=13-master script: - if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_BRANCH" == "master" ]]; then diff --git a/12-master/Dockerfile b/12-master/Dockerfile index 3eb95776c..060de7bcd 100644 --- a/12-master/Dockerfile +++ b/12-master/Dockerfile @@ -5,13 +5,13 @@ LABEL maintainer="PostGIS Project - https://postgis.net" ENV SFCGAL_VERSION master ENV SFCGAL_GIT_HASH 929605c8ea85f2c01efa116e1ed0eb01d285ea09 ENV PROJ_VERSION master -ENV PROJ_GIT_HASH 0c9cf39297a24d5e56aa488820a5ba3edaace90e +ENV PROJ_GIT_HASH 5d502d356e16ef81f481eb82dcdeba0ea3ab1f9e ENV GDAL_VERSION master -ENV GDAL_GIT_HASH ab634ff99f45ef87f2d3e862a56b2289bba653d5 +ENV GDAL_GIT_HASH 5adc1949498b536cc787920c99db965c20c03b69 ENV GEOS_VERSION master ENV GEOS_GIT_HASH 099e74b3127348e1f8544ab279b609e2fdc6cc74 ENV POSTGIS_VERSION master -ENV POSTGIS_GIT_HASH 4c185f8617824a21f46569170dd16c3427e1b197 +ENV POSTGIS_GIT_HASH 16121bf7939891022824152c0ca095aeebbad2ed RUN set -ex \ && apt-get update \ diff --git a/13-master/Dockerfile b/13-master/Dockerfile new file mode 100644 index 000000000..a5f9ddf42 --- /dev/null +++ b/13-master/Dockerfile @@ -0,0 +1,175 @@ +FROM postgres:13 + +LABEL maintainer="PostGIS Project - https://postgis.net" + +ENV SFCGAL_VERSION master +ENV SFCGAL_GIT_HASH 929605c8ea85f2c01efa116e1ed0eb01d285ea09 +ENV PROJ_VERSION master +ENV PROJ_GIT_HASH 5d502d356e16ef81f481eb82dcdeba0ea3ab1f9e +ENV GDAL_VERSION master +ENV GDAL_GIT_HASH 5adc1949498b536cc787920c99db965c20c03b69 +ENV GEOS_VERSION master +ENV GEOS_GIT_HASH 099e74b3127348e1f8544ab279b609e2fdc6cc74 +ENV POSTGIS_VERSION master +ENV POSTGIS_GIT_HASH 16121bf7939891022824152c0ca095aeebbad2ed + +RUN set -ex \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic1.67.0 \ + libboost-chrono1.67.0 \ + libboost-date-time1.67.0 \ + libboost-filesystem1.67.0 \ + libboost-program-options1.67.0 \ + libboost-serialization1.67.0 \ + libboost-system1.67.0 \ + libboost-test1.67.0 \ + libboost-thread1.67.0 \ + libboost-timer1.67.0 \ + libcgal13 \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c3 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff5 \ + libxml2 \ + sqlite3 \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + git \ + g++ \ + libboost-all-dev \ + libcgal-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + # sfcgal + && mkdir -p /usr/src/sfcgal \ + && cd /usr/src/sfcgal \ + && git init \ + && git remote add origin https://github.com/Oslandia/SFCGAL.git \ + && git fetch --depth 1 origin :${SFCGAL_GIT_HASH} \ + && git reset --hard FETCH_HEAD \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/sfcgal \ + # proj4 + && mkdir -p /usr/src/proj \ + && cd /usr/src/proj \ + && git init \ + && git remote add origin https://github.com/OSGeo/PROJ.git \ + && git fetch --depth 1 origin :${PROJ_GIT_HASH} \ + && git reset --hard FETCH_HEAD \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/proj \ + # geos + && mkdir -p /usr/src/geos \ + && cd /usr/src/geos \ + && git init \ + && git remote add origin https://github.com/libgeos/geos.git \ + && git fetch --depth 1 origin :${GEOS_GIT_HASH} \ + && git reset --hard FETCH_HEAD \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos \ + # gdal + && mkdir -p /usr/src/gdal \ + && cd /usr/src/gdal \ + && git init \ + && git remote add origin https://github.com/OSGeo/gdal.git \ + && git fetch --depth 1 origin :${GDAL_GIT_HASH} \ + && git reset --hard FETCH_HEAD \ + && cd gdal \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal \ + # postgis + && mkdir -p /usr/src/postgis \ + && cd /usr/src/postgis \ + && git init \ + && git remote add origin https://git.osgeo.org/gitea/postgis/postgis.git \ + && git fetch --depth 1 origin :${POSTGIS_GIT_HASH} \ + && git reset --hard FETCH_HEAD \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ +# --with-gui \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + git \ + g++ \ + libboost-all-dev \ + libcgal-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && rm -rf /var/lib/apt/lists/* \ + # Minimal command line test. + && cs2cs \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + diff --git a/13-master/README.md b/13-master/README.md new file mode 100644 index 000000000..2908ca3d7 --- /dev/null +++ b/13-master/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 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 both 2.5.x and 3.0.x for each supported version of Postgres (9.5, 9.6, 10, 11, and 12). Additionally, an image version is provided which is built from the latest version of Postgres (12) with versions of PostGIS and its dependencies built from their respective master branches. + +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/13-master/initdb-postgis.sh b/13-master/initdb-postgis.sh new file mode 100644 index 000000000..cdde274f5 --- /dev/null +++ b/13-master/initdb-postgis.sh @@ -0,0 +1,22 @@ +#!/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 IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/13-master/update-postgis.sh b/13-master/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/13-master/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