Skip to content

Commit 39ec46f

Browse files
authored
experiment: alpine3.14 + postgis2.5 (#244)
* update alpine template * update alpine Dockerfiles * update 9.6-2.5 alpine * update 3.1 alpin * revert Dockerfile.alpine.template * fix alpine3.14 with custom geos for 2.5 * update.sh * Remove 9.5-3.0, 9.5-2.5 (EOL) * Remove 9.5 CI (EOL) * refactor alpine template * ./update.sh
1 parent a75c70d commit 39ec46f

39 files changed

+706
-745
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,13 @@ jobs:
1515
make-docker-images:
1616
strategy:
1717
matrix:
18-
postgres: [9.5, 9.6, 10, 11, 12, 13]
18+
postgres: [9.6, 10, 11, 12, 13]
1919
postgis: ['2.5', '3.1']
2020
variant: [default, alpine]
2121
exclude:
2222
- postgres: 13
2323
postgis: '2.5'
24-
- postgres: 9.5
25-
postgis: '3.1'
2624
include:
27-
- postgres: 9.5
28-
postgis: '3.0'
29-
variant: default
30-
- postgres: 9.5
31-
postgis: '3.0'
32-
variant: alpine
3325
- postgres: 12
3426
postgis: master
3527
variant: default

10-2.5/README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ This image ensures that the default database created by the parent `postgres` im
88

99
* `postgis`
1010
* `postgis_topology`
11-
* `fuzzystrmatch`
1211
* `postgis_tiger_geocoder`
1312

13+
Note: As of PostGIS v3.x, raster has been factored out into a separate extension `postgis_raster` which must be installed separately.
14+
1415
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`.
1516

1617
## Usage
@@ -21,10 +22,21 @@ In order to run a basic container capable of serving a PostGIS-enabled database,
2122

2223
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/).
2324

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'
25+
Once you have started a database container, you can then connect to the database either directly on the running container:
26+
27+
docker exec -ti some-postgis psql -U postgres
28+
29+
... or starting a new container to run as a client. In this case you can use a user-defined network to link both containers:
30+
31+
docker network create some-network
32+
33+
# Server container
34+
docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis
35+
36+
# Client container
37+
docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres
38+
39+
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.
2840

2941
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.
3042

10-2.5/alpine/Dockerfile

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ LABEL maintainer="PostGIS Project - https://postgis.net"
55
ENV POSTGIS_VERSION 2.5.5
66
ENV POSTGIS_SHA256 24b15ee36f3af02015da0e92a18f9046ea0b4fd24896196c8e6c2aa8e4b56baa
77

8-
RUN set -ex \
8+
#Temporary fix:
9+
# for PostGIS 2.* - building a special geos
10+
# reason: PostGIS 2.5.5 is not working with GEOS 3.9.*
11+
ENV POSTGIS2_GEOS_VERSION tags/3.8.2
12+
13+
RUN set -eux \
914
\
1015
&& apk add --no-cache --virtual .fetch-deps \
1116
ca-certificates \
@@ -25,53 +30,81 @@ RUN set -ex \
2530
&& apk add --no-cache --virtual .build-deps \
2631
autoconf \
2732
automake \
33+
clang-dev \
2834
file \
35+
g++ \
36+
gcc \
37+
gdal-dev \
38+
gettext-dev \
2939
json-c-dev \
3040
libtool \
3141
libxml2-dev \
42+
llvm11-dev \
3243
make \
44+
pcre-dev \
3345
perl \
34-
clang-dev \
35-
g++ \
36-
gcc \
37-
gdal-dev \
38-
geos-dev \
39-
llvm10-dev \
4046
proj-dev \
4147
protobuf-c-dev \
42-
pcre-dev \
48+
\
49+
# GEOS setup
50+
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
51+
apk add --no-cache --virtual .build-deps-geos geos-dev cunit-dev ; \
52+
elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \
53+
apk add --no-cache --virtual .build-deps-geos cmake git ; \
54+
cd /usr/src ; \
55+
git clone https://github.com/libgeos/geos.git ; \
56+
cd geos ; \
57+
git checkout ${POSTGIS2_GEOS_VERSION} -b geos_build ; \
58+
mkdir cmake-build ; \
59+
cd cmake-build ; \
60+
cmake -DCMAKE_BUILD_TYPE=Release .. ; \
61+
make -j$(nproc) ; \
62+
make check ; \
63+
make install ; \
64+
cd / ; \
65+
rm -fr /usr/src/geos ; \
66+
else \
67+
echo ".... unknown PosGIS ...." ; \
68+
fi \
69+
\
70+
# build PostGIS
71+
\
4372
&& cd /usr/src/postgis \
73+
&& gettextize \
4474
&& ./autogen.sh \
45-
# configure options taken from:
46-
# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie
4775
&& ./configure \
48-
# --with-gui \
4976
--with-pcredir="$(pcre-config --prefix)" \
5077
&& make -j$(nproc) \
5178
&& make install \
79+
\
5280
# regress check
5381
&& mkdir /tempdb \
5482
&& chown -R postgres:postgres /tempdb \
5583
&& su postgres -c 'pg_ctl -D /tempdb init' \
5684
&& su postgres -c 'pg_ctl -D /tempdb start' \
5785
&& cd regress \
58-
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
86+
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
87+
#&& make -j$(nproc) check RUNTESTFLAGS=--dumprestore PGUSER=postgres \
88+
#&& make garden PGUSER=postgres \
5989
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
6090
&& rm -rf /tempdb \
6191
&& rm -rf /tmp/pgis_reg \
6292
# add .postgis-rundeps
6393
&& apk add --no-cache --virtual .postgis-rundeps \
64-
json-c \
65-
geos \
6694
gdal \
67-
proj \
68-
pcre \
95+
json-c \
6996
libstdc++ \
97+
pcre \
98+
proj \
7099
protobuf-c \
100+
# Geos setup
101+
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
102+
apk add --no-cache --virtual .postgis-rundeps-geos geos ; \
103+
fi \
71104
# clean
72105
&& cd / \
73106
&& rm -rf /usr/src/postgis \
74-
&& apk del .fetch-deps .build-deps
107+
&& apk del .fetch-deps .build-deps .build-deps-geos
75108

76109
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
77110
COPY ./update-postgis.sh /usr/local/bin

10-3.1/README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ This image ensures that the default database created by the parent `postgres` im
88

99
* `postgis`
1010
* `postgis_topology`
11-
* `fuzzystrmatch`
1211
* `postgis_tiger_geocoder`
1312

13+
Note: As of PostGIS v3.x, raster has been factored out into a separate extension `postgis_raster` which must be installed separately.
14+
1415
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`.
1516

1617
## Usage
@@ -21,10 +22,21 @@ In order to run a basic container capable of serving a PostGIS-enabled database,
2122

2223
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/).
2324

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'
25+
Once you have started a database container, you can then connect to the database either directly on the running container:
26+
27+
docker exec -ti some-postgis psql -U postgres
28+
29+
... or starting a new container to run as a client. In this case you can use a user-defined network to link both containers:
30+
31+
docker network create some-network
32+
33+
# Server container
34+
docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis
35+
36+
# Client container
37+
docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres
38+
39+
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.
2840

2941
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.
3042

10-3.1/alpine/Dockerfile

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ LABEL maintainer="PostGIS Project - https://postgis.net"
55
ENV POSTGIS_VERSION 3.1.2
66
ENV POSTGIS_SHA256 c49b6baa4afe4aed6cc7333399897aaf7540b40779a939a4d5a81d0725f6c9f8
77

8-
RUN set -ex \
8+
#Temporary fix:
9+
# for PostGIS 2.* - building a special geos
10+
# reason: PostGIS 2.5.5 is not working with GEOS 3.9.*
11+
ENV POSTGIS2_GEOS_VERSION tags/3.8.2
12+
13+
RUN set -eux \
914
\
1015
&& apk add --no-cache --virtual .fetch-deps \
1116
ca-certificates \
@@ -25,53 +30,81 @@ RUN set -ex \
2530
&& apk add --no-cache --virtual .build-deps \
2631
autoconf \
2732
automake \
33+
clang-dev \
2834
file \
35+
g++ \
36+
gcc \
37+
gdal-dev \
38+
gettext-dev \
2939
json-c-dev \
3040
libtool \
3141
libxml2-dev \
42+
llvm11-dev \
3243
make \
44+
pcre-dev \
3345
perl \
34-
clang-dev \
35-
g++ \
36-
gcc \
37-
gdal-dev \
38-
geos-dev \
39-
llvm10-dev \
4046
proj-dev \
4147
protobuf-c-dev \
42-
pcre-dev \
48+
\
49+
# GEOS setup
50+
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
51+
apk add --no-cache --virtual .build-deps-geos geos-dev cunit-dev ; \
52+
elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \
53+
apk add --no-cache --virtual .build-deps-geos cmake git ; \
54+
cd /usr/src ; \
55+
git clone https://github.com/libgeos/geos.git ; \
56+
cd geos ; \
57+
git checkout ${POSTGIS2_GEOS_VERSION} -b geos_build ; \
58+
mkdir cmake-build ; \
59+
cd cmake-build ; \
60+
cmake -DCMAKE_BUILD_TYPE=Release .. ; \
61+
make -j$(nproc) ; \
62+
make check ; \
63+
make install ; \
64+
cd / ; \
65+
rm -fr /usr/src/geos ; \
66+
else \
67+
echo ".... unknown PosGIS ...." ; \
68+
fi \
69+
\
70+
# build PostGIS
71+
\
4372
&& cd /usr/src/postgis \
73+
&& gettextize \
4474
&& ./autogen.sh \
45-
# configure options taken from:
46-
# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie
4775
&& ./configure \
48-
# --with-gui \
4976
--with-pcredir="$(pcre-config --prefix)" \
5077
&& make -j$(nproc) \
5178
&& make install \
79+
\
5280
# regress check
5381
&& mkdir /tempdb \
5482
&& chown -R postgres:postgres /tempdb \
5583
&& su postgres -c 'pg_ctl -D /tempdb init' \
5684
&& su postgres -c 'pg_ctl -D /tempdb start' \
5785
&& cd regress \
58-
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
86+
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
87+
#&& make -j$(nproc) check RUNTESTFLAGS=--dumprestore PGUSER=postgres \
88+
#&& make garden PGUSER=postgres \
5989
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
6090
&& rm -rf /tempdb \
6191
&& rm -rf /tmp/pgis_reg \
6292
# add .postgis-rundeps
6393
&& apk add --no-cache --virtual .postgis-rundeps \
64-
json-c \
65-
geos \
6694
gdal \
67-
proj \
68-
pcre \
95+
json-c \
6996
libstdc++ \
97+
pcre \
98+
proj \
7099
protobuf-c \
100+
# Geos setup
101+
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \
102+
apk add --no-cache --virtual .postgis-rundeps-geos geos ; \
103+
fi \
71104
# clean
72105
&& cd / \
73106
&& rm -rf /usr/src/postgis \
74-
&& apk del .fetch-deps .build-deps
107+
&& apk del .fetch-deps .build-deps .build-deps-geos
75108

76109
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
77110
COPY ./update-postgis.sh /usr/local/bin

11-2.5/README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ This image ensures that the default database created by the parent `postgres` im
88

99
* `postgis`
1010
* `postgis_topology`
11-
* `fuzzystrmatch`
1211
* `postgis_tiger_geocoder`
1312

13+
Note: As of PostGIS v3.x, raster has been factored out into a separate extension `postgis_raster` which must be installed separately.
14+
1415
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`.
1516

1617
## Usage
@@ -21,10 +22,21 @@ In order to run a basic container capable of serving a PostGIS-enabled database,
2122

2223
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/).
2324

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'
25+
Once you have started a database container, you can then connect to the database either directly on the running container:
26+
27+
docker exec -ti some-postgis psql -U postgres
28+
29+
... or starting a new container to run as a client. In this case you can use a user-defined network to link both containers:
30+
31+
docker network create some-network
32+
33+
# Server container
34+
docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis
35+
36+
# Client container
37+
docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres
38+
39+
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.
2840

2941
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.
3042

0 commit comments

Comments
 (0)