diff --git a/README.md b/README.md index 9b2f1a6..7d7a182 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,11 @@ differentiates itself by: * provides ssl support out of the box * connections are restricted to the docker subnet -* template_postgis database template is created for you * a default database 'gis' is created for you so you can use this container 'out of the box' when it runs with e.g. QGIS * replication support included +* Ability to create multiple database when you spin the database. +* Enable multiple extensions in the database when setting it up We will work to add more security features to this container in the future with the aim of making a PostGIS image that is ready to be used in a production @@ -87,11 +88,12 @@ sudo docker run --name "postgis" -p 25432:5432 -d -t kartoza/postgis ## Environment variables You can also use the following environment variables to pass a -user name, password and/or default database name. +user name, password and/or default database name(or multiple databases coma separated). * -e POSTGRES_USER= * -e POSTGRES_PASS= * -e POSTGRES_DBNAME= +* -e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology # You can pass as many extensions as you need. These will be used to create a new superuser with your preferred credentials. If these are not specified then the postgresql diff --git a/docker-compose.yml b/docker-compose.yml index 09a3ab3..40f60e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ # docker-compose build # docker-compose up -d web -version: '2' +version: '2.1' volumes: dbbackups: postgis-data: @@ -8,21 +8,26 @@ volumes: services: db: - image: kartoza/postgis:10.0-2.4 + image: kartoza/postgis:11.0-2.5 volumes: - - 'postgis-data:/var/lib/postgresql' - - 'dbbackups:/backups' + - postgis-data:/var/lib/postgresql + - dbbackups:/backups environment: + # If you need to create multiple database you can add coma separated databases eg gis,data - POSTGRES_DB=gis - POSTGRES_USER=docker - POSTGRES_PASS=docker - ALLOW_IP_RANGE=0.0.0.0/0 + # Add extensions you need to be enabled by default in the DB. Default are the three specified below + #- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology ports: - - 25432:5432 - restart: unless-stopped + - 5434:5432 + restart: on-failure + healthcheck: + test: "exit 0" dbbackups: - image: kartoza/pg-backup:10.0 + image: kartoza/pg-backup:11.0 hostname: pg-backups volumes: - dbbackups:/backups @@ -35,4 +40,7 @@ services: - PGDATABASE=gis - PGPORT=5432 - PGHOST=db - restart: unless-stopped + restart: on-failure + depends_on: + db: + condition: service_healthy diff --git a/env-data.sh b/env-data.sh index be1731b..f2e8bc3 100644 --- a/env-data.sh +++ b/env-data.sh @@ -44,16 +44,19 @@ if [ -z "${DESTROY_DATABASE_ON_RESTART}" ]; then DESTROY_DATABASE_ON_RESTART=true fi if [ -z "${PG_MAX_WAL_SENDERS}" ]; then - PG_MAX_WAL_SENDERS=8 + PG_MAX_WAL_SENDERS=10 fi if [ -z "${PG_WAL_KEEP_SEGMENTS}" ]; then - PG_WAL_KEEP_SEGMENTS=100 + PG_WAL_KEEP_SEGMENTS=250 fi if [ -z "${IP_LIST}" ]; then IP_LIST='*' fi +if [ -z "${POSTGRES_MULTIPLE_EXTENSIONS}" ]; then + POSTGRES_MULTIPLE_EXTENSIONS='postgis,hstore,postgis_topology' +fi # Compatibility with official postgres variable # Official postgres variable gets priority if [ ! -z "${POSTGRES_PASSWORD}" ]; then diff --git a/sample/replication/docker-compose.yml b/sample/replication/docker-compose.yml index b424b7e..08c94f9 100644 --- a/sample/replication/docker-compose.yml +++ b/sample/replication/docker-compose.yml @@ -24,6 +24,9 @@ services: # We can specify optional credentials POSTGRES_USER: 'docker' POSTGRES_PASS: 'docker' + # Setup master replication variables + #PG_MAX_WAL_SENDERS: 8 + #PG_WAL_KEEP_SEGMENTS: 100 # You can expose the port to observe it in your local machine ports: - "7777:5432" diff --git a/setup-conf.sh b/setup-conf.sh index 6de4912..73034f3 100644 --- a/setup-conf.sh +++ b/setup-conf.sh @@ -15,21 +15,21 @@ cat $CONF.template > $CONF # This script will setup necessary configuration to optimise for PostGIS and to enable replications cat >> $CONF < ${DATADIR}/recovery.conf <