forked from postgis/docker-postgis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add postgis/postgis:14beta2-3.1 versions (postgis#249)
* add 14beta2 update scripts - No "postgres:14" images; only "postgres:14beta2" and "postgres:14beta2-alpine" so I have made some quick&dirty changes The Postgres-betas internal format can be change; so the new tagging is better for the users. typical error: "The database cluster was initialized with CATALOG_VERSION_NO" related: postgis#228 - I have updated some upstream master to main. * add 14beta2-3.1/* files ; generated by ./update.sh * Manual update the alpine files to 3.1.3 The debain version is still on 3.1.2 ; but this unmodified version is not working with beta2 see: https://postgis.net/2021/07/02/postgis-3.1.3/ * add updated (12|13)-master Dockerfiles
- Loading branch information
Showing
11 changed files
with
318 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM postgres:14beta2 | ||
|
||
LABEL maintainer="PostGIS Project - https://postgis.net" | ||
|
||
ENV POSTGIS_MAJOR 3 | ||
ENV POSTGIS_VERSION 3.1.2+dfsg-1~exp2.pgdg100+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/10_postgis.sh | ||
COPY ./update-postgis.sh /usr/local/bin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# postgis/postgis | ||
|
||
[![Build Status](https://github.com/postgis/docker-postgis/workflows/Docker%20PostGIS%20CI/badge.svg)](https://github.com/postgis/docker-postgis/actions) [![Join the chat at https://gitter.im/postgis/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/postgis/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
|
||
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.1.x for each supported version of Postgres (9.5, 9.6, 10, 11, 12 and 13). Additionally, an image version is provided which is built from the latest version of Postgres (13) 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` | ||
* `postgis_tiger_geocoder` | ||
|
||
Note: As of PostGIS v3.x, raster has been factored out into a separate extension `postgis_raster` which must be installed separately. | ||
|
||
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 either directly on the running container: | ||
|
||
docker exec -ti some-postgis psql -U postgres | ||
|
||
... or starting a new container to run as a client. In this case you can use a user-defined network to link both containers: | ||
|
||
docker network create some-network | ||
|
||
# Server container | ||
docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis | ||
|
||
# Client container | ||
docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres | ||
|
||
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. | ||
|
||
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
FROM postgres:14beta2-alpine | ||
|
||
LABEL maintainer="PostGIS Project - https://postgis.net" | ||
|
||
ENV POSTGIS_VERSION 3.1.3 | ||
ENV POSTGIS_SHA256 885e11b26d8385aff49e605d33749a83e711180a3b1996395564ddf6346f3bb4 | ||
|
||
#Temporary fix: | ||
# for PostGIS 2.* - building a special geos | ||
# reason: PostGIS 2.5.5 is not working with GEOS 3.9.* | ||
ENV POSTGIS2_GEOS_VERSION tags/3.8.2 | ||
|
||
RUN set -eux \ | ||
\ | ||
&& 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 \ | ||
clang-dev \ | ||
file \ | ||
g++ \ | ||
gcc \ | ||
gdal-dev \ | ||
gettext-dev \ | ||
json-c-dev \ | ||
libtool \ | ||
libxml2-dev \ | ||
llvm11-dev \ | ||
make \ | ||
pcre-dev \ | ||
perl \ | ||
proj-dev \ | ||
protobuf-c-dev \ | ||
\ | ||
# GEOS setup | ||
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \ | ||
apk add --no-cache --virtual .build-deps-geos geos-dev cunit-dev ; \ | ||
elif [ $(printf %.1s "$POSTGIS_VERSION") == 2 ]; then \ | ||
apk add --no-cache --virtual .build-deps-geos cmake git ; \ | ||
cd /usr/src ; \ | ||
git clone https://github.com/libgeos/geos.git ; \ | ||
cd geos ; \ | ||
git checkout ${POSTGIS2_GEOS_VERSION} -b geos_build ; \ | ||
mkdir cmake-build ; \ | ||
cd cmake-build ; \ | ||
cmake -DCMAKE_BUILD_TYPE=Release .. ; \ | ||
make -j$(nproc) ; \ | ||
make check ; \ | ||
make install ; \ | ||
cd / ; \ | ||
rm -fr /usr/src/geos ; \ | ||
else \ | ||
echo ".... unknown PosGIS ...." ; \ | ||
fi \ | ||
\ | ||
# build PostGIS | ||
\ | ||
&& cd /usr/src/postgis \ | ||
&& gettextize \ | ||
&& ./autogen.sh \ | ||
&& ./configure \ | ||
--with-pcredir="$(pcre-config --prefix)" \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
\ | ||
# regress check | ||
&& mkdir /tempdb \ | ||
&& chown -R postgres:postgres /tempdb \ | ||
&& su postgres -c 'pg_ctl -D /tempdb init' \ | ||
&& su postgres -c 'pg_ctl -D /tempdb start' \ | ||
&& cd regress \ | ||
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ | ||
#&& make -j$(nproc) check RUNTESTFLAGS=--dumprestore PGUSER=postgres \ | ||
#&& make garden PGUSER=postgres \ | ||
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ | ||
&& rm -rf /tempdb \ | ||
&& rm -rf /tmp/pgis_reg \ | ||
# add .postgis-rundeps | ||
&& apk add --no-cache --virtual .postgis-rundeps \ | ||
gdal \ | ||
json-c \ | ||
libstdc++ \ | ||
pcre \ | ||
proj \ | ||
protobuf-c \ | ||
# Geos setup | ||
&& if [ $(printf %.1s "$POSTGIS_VERSION") == 3 ]; then \ | ||
apk add --no-cache --virtual .postgis-rundeps-geos geos ; \ | ||
fi \ | ||
# clean | ||
&& cd / \ | ||
&& rm -rf /usr/src/postgis \ | ||
&& apk del .fetch-deps .build-deps .build-deps-geos | ||
|
||
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh | ||
COPY ./update-postgis.sh /usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.