diff --git a/postgres/Dockerfile b/postgres/Dockerfile index d737976..f7024bf 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,3 +1,5 @@ FROM postgres:latest COPY postgres/setup.sh /docker-entrypoint-initdb.d/setup.sh +COPY postgres/standby_setup.sh /standby_setup.sh RUN chmod 0666 /docker-entrypoint-initdb.d/setup.sh +RUN chmod 0700 /standby_setup.sh diff --git a/postgres/standby_setup.sh b/postgres/standby_setup.sh new file mode 100644 index 0000000..045b32c --- /dev/null +++ b/postgres/standby_setup.sh @@ -0,0 +1,23 @@ +#! /bin/bash + + +if [ ! -s "$PGDATA/PG_VERSION" ]; then + + pg_basebackup -d "host=$MASTER_NODE password=$REPLICATION_PASSWORD port=5432 user=$REPLICATION_USER" -D ${PGDATA} -vP + + set -e + + cat > ${PGDATA}/recovery.conf <