Skip to content

Commit 05f263c

Browse files
committed
add 13-3.0 debian + alpine ; and improve update.sh
Changes to be committed: modified: .travis.yml modified: 10-3.0/Dockerfile modified: 11-3.0/Dockerfile modified: 12-3.0/Dockerfile modified: 12-master/Dockerfile new file: 13-3.0/Dockerfile new file: 13-3.0/README.md new file: 13-3.0/alpine/Dockerfile new file: 13-3.0/alpine/initdb-postgis.sh new file: 13-3.0/alpine/update-postgis.sh new file: 13-3.0/initdb-postgis.sh new file: 13-3.0/update-postgis.sh modified: 13-master/Dockerfile modified: 9.5-3.0/Dockerfile modified: 9.6-3.0/Dockerfile modified: update.sh
1 parent 6e1c11f commit 05f263c

File tree

16 files changed

+253
-11
lines changed

16 files changed

+253
-11
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ dist: xenial
66

77
env:
88
- VERSION=13-master
9+
- VERSION=13-3.0
10+
- VERSION=13-3.0 VARIANT=alpine
911
- VERSION=12-master
1012
- VERSION=12-3.0
1113
- VERSION=12-3.0 VARIANT=alpine

10-3.0/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM postgres:10
33
LABEL maintainer="PostGIS Project - https://postgis.net"
44

55
ENV POSTGIS_MAJOR 3
6-
ENV POSTGIS_VERSION 3.0.1+dfsg-2.pgdg90+1
6+
ENV POSTGIS_VERSION 3.0.1+dfsg-4.pgdg90+1
77

88
RUN apt-get update \
99
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \

11-3.0/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM postgres:11
33
LABEL maintainer="PostGIS Project - https://postgis.net"
44

55
ENV POSTGIS_MAJOR 3
6-
ENV POSTGIS_VERSION 3.0.1+dfsg-2.pgdg90+1
6+
ENV POSTGIS_VERSION 3.0.1+dfsg-4.pgdg90+1
77

88
RUN apt-get update \
99
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \

12-3.0/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM postgres:12
33
LABEL maintainer="PostGIS Project - https://postgis.net"
44

55
ENV POSTGIS_MAJOR 3
6-
ENV POSTGIS_VERSION 3.0.1+dfsg-2.pgdg100+1
6+
ENV POSTGIS_VERSION 3.0.1+dfsg-4.pgdg100+1
77

88
RUN apt-get update \
99
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \

12-master/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ENV SFCGAL_GIT_HASH 7e91a52fd90ef47e2f0b8925145e59ef1043fdd4
77
ENV PROJ_VERSION master
88
ENV PROJ_GIT_HASH 062c7f160f4b1d41f82730fa6eb6653e78ade74a
99
ENV GDAL_VERSION master
10-
ENV GDAL_GIT_HASH d5292796a67de8973cc58cbf20f2d25a38d3e293
10+
ENV GDAL_GIT_HASH 8591a08cebe8cd9b5ff4b382a7e6386f6a76a74b
1111
ENV GEOS_VERSION master
1212
ENV GEOS_GIT_HASH 0f938979b58f9a451670032a7199ece23d52c3c1
1313
ENV POSTGIS_VERSION master

13-3.0/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM postgres:13
2+
3+
LABEL maintainer="PostGIS Project - https://postgis.net"
4+
5+
ENV POSTGIS_MAJOR 3
6+
ENV POSTGIS_VERSION 3.0.1+dfsg-4.pgdg100+1
7+
8+
RUN apt-get update \
9+
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
10+
&& apt-get install -y --no-install-recommends \
11+
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
12+
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
RUN mkdir -p /docker-entrypoint-initdb.d
16+
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
17+
COPY ./update-postgis.sh /usr/local/bin
18+

13-3.0/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# postgis/postgis
2+
3+
[![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)
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 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.
6+
7+
This image ensures that the default database created by the parent `postgres` image will have the following extensions installed:
8+
9+
* `postgis`
10+
* `postgis_topology`
11+
* `fuzzystrmatch`
12+
* `postgis_tiger_geocoder`
13+
14+
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`.
15+
16+
## Usage
17+
18+
In order to run a basic container capable of serving a PostGIS-enabled database, start a container as follows:
19+
20+
docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis
21+
22+
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/).
23+
24+
Once you have started a database container, you can then connect to the database as follows:
25+
26+
docker run -it --link some-postgis:postgres --rm postgres \
27+
sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
28+
29+
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.
30+
31+
## Known Issues / Errors
32+
33+
When You encouter errors due to PostGIS update `OperationalError: could not access file "$libdir/postgis-X.X`, run:
34+
35+
`docker exec some-postgis update-postgis.sh`
36+
37+
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:
38+
39+
```
40+
Updating PostGIS extensions template_postgis to X.X.X
41+
NOTICE: version "X.X.X" of extension "postgis" is already installed
42+
NOTICE: version "X.X.X" of extension "postgis_topology" is already installed
43+
NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed
44+
ALTER EXTENSION
45+
Updating PostGIS extensions docker to X.X.X
46+
NOTICE: version "X.X.X" of extension "postgis" is already installed
47+
NOTICE: version "X.X.X" of extension "postgis_topology" is already installed
48+
NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed
49+
ALTER EXTENSION
50+
```
51+

13-3.0/alpine/Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
FROM postgres:13-alpine
2+
3+
LABEL maintainer="PostGIS Project - https://postgis.net"
4+
5+
ENV POSTGIS_VERSION 3.0.1
6+
ENV POSTGIS_SHA256 5451a34c0b9d65580b3ae44e01fefc9e1f437f3329bde6de8fefde66d025e228
7+
8+
RUN set -ex \
9+
\
10+
&& apk add --no-cache --virtual .fetch-deps \
11+
ca-certificates \
12+
openssl \
13+
tar \
14+
\
15+
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/$POSTGIS_VERSION.tar.gz" \
16+
&& echo "$POSTGIS_SHA256 *postgis.tar.gz" | sha256sum -c - \
17+
&& mkdir -p /usr/src/postgis \
18+
&& tar \
19+
--extract \
20+
--file postgis.tar.gz \
21+
--directory /usr/src/postgis \
22+
--strip-components 1 \
23+
&& rm postgis.tar.gz \
24+
\
25+
&& apk add --no-cache --virtual .build-deps \
26+
autoconf \
27+
automake \
28+
file \
29+
json-c-dev \
30+
libtool \
31+
libxml2-dev \
32+
make \
33+
perl \
34+
clang-dev \
35+
g++ \
36+
gcc \
37+
gdal-dev \
38+
geos-dev \
39+
llvm10-dev \
40+
proj-dev \
41+
protobuf-c-dev \
42+
&& cd /usr/src/postgis \
43+
&& ./autogen.sh \
44+
# configure options taken from:
45+
# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie
46+
&& ./configure \
47+
# --with-gui \
48+
&& make -j$(nproc) \
49+
&& make install \
50+
# regress check
51+
&& mkdir /tempdb \
52+
&& chown -R postgres:postgres /tempdb \
53+
&& su postgres -c 'pg_ctl -D /tempdb init' \
54+
&& su postgres -c 'pg_ctl -D /tempdb start' \
55+
&& cd regress \
56+
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
57+
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
58+
&& rm -rf /tempdb \
59+
# add .postgis-rundeps
60+
&& apk add --no-cache --virtual .postgis-rundeps \
61+
json-c \
62+
geos \
63+
gdal \
64+
proj \
65+
libstdc++ \
66+
protobuf-c \
67+
# clean
68+
&& cd / \
69+
&& rm -rf /usr/src/postgis \
70+
&& apk del .fetch-deps .build-deps
71+
72+
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
73+
COPY ./update-postgis.sh /usr/local/bin

13-3.0/alpine/initdb-postgis.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
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+
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
20+
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;
21+
EOSQL
22+
done

13-3.0/alpine/update-postgis.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

0 commit comments

Comments
 (0)