From c20600770896e489994d10aecd66e5b3b495c882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wieche=C4=87?= Date: Mon, 11 Jan 2016 10:09:50 +0100 Subject: [PATCH] fixing issue with PostGIS topology extension environment variable DB_POSTGIS_TOPOLOGY controls creation of 'postgis_topology' extension _only_ when user selects PostGIS extension. refs #44 --- README.md | 11 +++++++++++ runtime/env-defaults | 1 + runtime/functions | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d25145e..2f3ee11 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,17 @@ docker run --name postgresql -itd \ sameersbn/postgresql:9.4-11 ``` +Additionally, creation of PostGIS topology extension can be enabled by specifying `DB_POSTGIS_TOPOLOGY=true`: + + +```bash +docker run --name postgresql -itd \ + --env 'DB_NAME=dbname' --env 'DB_POSTGIS=true' --env DB_POSTGIS_TOPOLOGY=true \ + sameersbn/postgresql:9.4-11 +``` + +Note that topology extension creation can be enabled only when PostGIS extension is enabled. + *By default the PostGIS extension is disabled* ## Granting user access to a database diff --git a/runtime/env-defaults b/runtime/env-defaults index 854e1c5..6b92ba6 100644 --- a/runtime/env-defaults +++ b/runtime/env-defaults @@ -20,3 +20,4 @@ DB_TEMPLATE=${DB_TEMPLATE:-template1} DB_UNACCENT=${DB_UNACCENT:-false} DB_POSTGIS=${DB_POSTGIS:-false} +DB_POSTGIS_TOPOLOGY=${DB_POSTGIS_TOPOLOGY:-false} diff --git a/runtime/functions b/runtime/functions index e5314b3..e5b368a 100755 --- a/runtime/functions +++ b/runtime/functions @@ -326,7 +326,10 @@ create_database() { if [[ ${DB_POSTGIS} == true ]]; then echo "‣ Loading PostGIS extension..." psql -U ${PG_USER} -d ${database} -c "CREATE EXTENSION IF NOT EXISTS postgis;" >/dev/null 2>&1 - psql -U ${PG_USER} -d ${database} -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;" >/dev/null 2>&1 + if [[ ${DB_POSTGIS_TOPOLOGY} == true ]]; then + echo "‣ Loading PostGIS Topology extension..." + psql -U ${PG_USER} -d ${database} -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;" >/dev/null 2>&1 + fi fi if [[ -n ${DB_USER} ]]; then