Load vt-util functions into PostGIS template and setup OSM db

pull/20/head
Lukas Martinelli 2015-09-24 11:06:16 +02:00
rodzic ec9ed51f37
commit b38bad0e81
4 zmienionych plików z 40 dodań i 8 usunięć

Wyświetl plik

@ -1,4 +1,7 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
TYPE=$1
AREA=$2

Wyświetl plik

@ -1,4 +1,10 @@
FROM mdillon/postgis:9.4
# copy new initdb file which creates the hstore extension
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh
# download vt-util functions
ADD https://raw.githubusercontent.com/mapbox/postgis-vt-util/v1.0.0/postgis-vt-util.sql /opt/postgis-vt-util/
ENV VT_UTIL_DIR=/opt/postgis-vt-util
# copy new initdb file which enables the hstore extension and Mapbox vt-util functions
RUN rm -f /docker-entrypoint-initdb.d/postgis.sh
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
COPY ./initdb-osm.sh /docker-entrypoint-initdb.d/20_osm.sh

Wyświetl plik

@ -0,0 +1,18 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
OSM_DB=${OSM_DB:-osm}
OSM_USER=${OSM_USER:-osm}
OSM_PASS=${OSM_PASS:-osm}
# perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"
# create OSM database
echo "Creating database $OSM_DB with owner $OSM_USER"
psql --dbname="$POSTGRES_DB" <<- EOSQL
CREATE USER $OSM_DB WITH PASSWORD '$OSM_PASS';
CREATE DATABASE $OSM_DB WITH TEMPLATE template_postgis OWNER $OSM_USER;
EOSQL

Wyświetl plik

@ -1,19 +1,21 @@
#!/bin/sh
set -e
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# Perform all actions as $POSTGRES_USER
# perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"
# Create the 'template_postgis' template db
# create the 'template_postgis' template db
psql --dbname="$POSTGRES_DB" <<- 'EOSQL'
CREATE DATABASE template_postgis;
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
EOSQL
# Load PostGIS into both template_database and $POSTGRES_DB
# load PostGIS into both template_database and $POSTGRES_DB
cd "/usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR"
for DB in template_postgis "$POSTGRES_DB"; do
echo "Loading PostGIS into $DB via CREATE EXTENSION"
echo "Loading PostGIS into $DB"
psql --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION postgis;
CREATE EXTENSION hstore;
@ -22,3 +24,6 @@ for DB in template_postgis "$POSTGRES_DB"; do
CREATE EXTENSION postgis_tiger_geocoder;
EOSQL
done
echo "Loading vt-util functions into template_postgis"
psql --dbname="template_postgis" -f "$VT_UTIL_DIR/postgis-vt-util.sql"