-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Part one of porting work from 9.6 to 10 * Backported more scripts from 9.6 branch * Added missing apt update in dockerfile * Updates to entrypoint to reference image and update docker-compose to reference 10 pg * Added sample and docs from 9.6 branch * Removed my diagram as Rizky had already added one * Fix env paths for pg 10 * Fixes for backporting work from 9.6 to 10 - dbb now spins up and accepts connections properly
- Loading branch information
Showing
21 changed files
with
1,340 additions
and
310 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.idea | ||
*.*~ | ||
*/replication/pg-* | ||
*/replication/docker-compose.override.yml | ||
.DS_Store |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
docker build -t kartoza/postgis:manual-build . | ||
docker build -t kartoza/postgis:10.0-2.4 . |
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,38 @@ | ||
# docker-compose build | ||
# docker-compose up -d web | ||
version: '2' | ||
volumes: | ||
dbbackups: | ||
postgis-data: | ||
|
||
services: | ||
|
||
db: | ||
image: kartoza/postgis:10.0-2.4 | ||
volumes: | ||
- 'postgis-data:/var/lib/postgresql' | ||
- 'dbbackups:/backups' | ||
environment: | ||
- POSTGRES_DB=gis | ||
- POSTGRES_USER=docker | ||
- POSTGRES_PASS=docker | ||
- ALLOW_IP_RANGE=0.0.0.0/0 | ||
ports: | ||
- 25432:5432 | ||
restart: unless-stopped | ||
|
||
dbbackups: | ||
image: kartoza/pg-backup:10.0 | ||
hostname: pg-backups | ||
volumes: | ||
- dbbackups:/backups | ||
links: | ||
- db:db | ||
environment: | ||
- DUMPPREFIX=demo | ||
- PGUSER=docker | ||
- PGPASSWORD=docker | ||
- PGDATABASE=gis | ||
- PGPORT=5432 | ||
- PGHOST=db | ||
restart: unless-stopped |
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,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script will run as the postgres user due to the Dockerfile USER directive | ||
set -e | ||
|
||
# Setup postgres CONF file | ||
source /setup-conf.sh | ||
|
||
# Setup ssl | ||
source /setup-ssl.sh | ||
|
||
# Setup pg_hba.conf | ||
source /setup-pg_hba.sh | ||
|
||
if [ -z "$REPLICATE_FROM" ]; then | ||
# This means this is a master instance. We check that database exists | ||
echo "Setup master database" | ||
source /setup-database.sh | ||
else | ||
# This means this is a slave/replication instance. | ||
echo "Setup slave database" | ||
source /setup-replication.sh | ||
fi | ||
|
||
# Running extended script or sql if provided. | ||
# Useful for people who extends the image. | ||
|
||
echo | ||
for f in /docker-entrypoint-initdb.d/*; do | ||
case "$f" in | ||
*.sh) echo "$0: running $f"; . "$f" ;; | ||
*.sql) echo "$0: running $f"; "${psql[@]}" < "$f"; echo ;; | ||
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; | ||
*) echo "$0: ignoring $f" ;; | ||
esac | ||
echo | ||
done | ||
|
||
# If no arguments passed to entrypoint, then run postgres by default | ||
if [ $# -eq 0 ]; | ||
then | ||
echo "Postgres initialisation process completed .... restarting in foreground" | ||
cat /tmp/postgresql.conf > ${CONF} | ||
su - postgres -c "$SETVARS $POSTGRES -D $DATADIR -c config_file=$CONF" | ||
fi | ||
|
||
# If arguments passed, run postgres with these arguments | ||
# This will make sure entrypoint will always be executed | ||
if [ "${1:0:1}" = '-' ]; then | ||
# append postgres into the arguments | ||
set -- postgres "$@" | ||
fi | ||
|
||
exec su - "$@" |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,64 @@ | ||
#!/usr/bin/env bash | ||
|
||
DATADIR="/var/lib/postgresql/10/main" | ||
ROOT_CONF="/etc/postgresql/10/main" | ||
CONF="$ROOT_CONF/postgresql.conf" | ||
RECOVERY_CONF="$ROOT_CONF/recovery.conf" | ||
POSTGRES="/usr/lib/postgresql/10/bin/postgres" | ||
INITDB="/usr/lib/postgresql/10/bin/initdb" | ||
SQLDIR="/usr/share/postgresql/10/contrib/postgis-2.4/" | ||
SETVARS="POSTGIS_ENABLE_OUTDB_RASTERS=1 POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL" | ||
LOCALONLY="-c listen_addresses='127.0.0.1'" | ||
PG_BASEBACKUP="/usr/bin/pg_basebackup" | ||
PROMOTE_FILE="/tmp/pg_promote_master" | ||
PGSTAT_TMP="/var/run/postgresql/" | ||
PG_PID="/var/run/postgresql/10-main.pid" | ||
|
||
# Make sure we have a user set up | ||
if [ -z "${POSTGRES_USER}" ]; then | ||
POSTGRES_USER=docker | ||
fi | ||
if [ -z "${POSTGRES_PASS}" ]; then | ||
POSTGRES_PASS=docker | ||
fi | ||
if [ -z "${POSTGRES_DBNAME}" ]; then | ||
POSTGRES_DBNAME=gis | ||
fi | ||
# SSL mode | ||
if [ -z "${PGSSLMODE}" ]; then | ||
PGSSLMODE=require | ||
fi | ||
# Enable hstore and topology by default | ||
if [ -z "${HSTORE}" ]; then | ||
HSTORE=true | ||
fi | ||
if [ -z "${TOPOLOGY}" ]; then | ||
TOPOLOGY=true | ||
fi | ||
# Replication settings | ||
if [ -z "${REPLICATE_PORT}" ]; then | ||
REPLICATE_PORT=5432 | ||
fi | ||
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 | ||
fi | ||
if [ -z "${PG_WAL_KEEP_SEGMENTS}" ]; then | ||
PG_WAL_KEEP_SEGMENTS=100 | ||
fi | ||
|
||
|
||
# Compatibility with official postgres variable | ||
# Official postgres variable gets priority | ||
if [ ! -z "${POSTGRES_PASSWORD}" ]; then | ||
POSTGRES_PASS=${POSTGRES_PASSWORD} | ||
fi | ||
if [ ! -z "${PGDATA}" ]; then | ||
DATADIR=${PGDATA} | ||
fi | ||
|
||
if [ ! -z "$POSTGRES_DB" ]; then | ||
POSTGRES_DBNAME=${POSTGRES_DB} | ||
fi |
Oops, something went wrong.