-
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.
postgis extension added to postgresql docker image.
- Loading branch information
1 parent
b89ec93
commit d60021e
Showing
4 changed files
with
129 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,79 @@ | ||
FROM postgres:12.3-alpine | ||
FROM postgres:12-alpine | ||
|
||
LABEL maintainer="PostGIS Project - https://postgis.net" | ||
|
||
ENV POSTGIS_VERSION 3.0.2 | ||
ENV POSTGIS_SHA256 2d4eb79ea9af1257320922a8a7d2663d37189c805746e975a5951ee6dc5ac4ef | ||
|
||
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 \ | ||
llvm10-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 -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 \ | ||
&& 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 \ | ||
json-c \ | ||
geos \ | ||
gdal \ | ||
proj \ | ||
libstdc++ \ | ||
protobuf-c \ | ||
# clean | ||
&& cd / \ | ||
&& rm -rf /usr/src/postgis \ | ||
&& apk del .fetch-deps .build-deps | ||
|
||
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh | ||
COPY ./update-postgis.sh /usr/local/bin | ||
|
||
COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ | ||
# RUN chown postgres:postgres /docker-entrypoint-initdb.d/ | ||
RUN chown postgres:postgres /docker-entrypoint-initdb.d/ | ||
|
||
EXPOSE 5432 | ||
EXPOSE 5432 |
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 |