Replication working

pull/73/head
Christopher Usher 5 years ago
parent 37b0efb66a
commit 38801ea6d3

@ -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

@ -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 <<EOF
standby_mode = on
primary_conninfo = 'host=$MASTER_NODE password=$REPLICATION_PASSWORD port=5432 user=$REPLICATION_USER'
trigger_file = '/tmp/touch_me_to_promote_to_me_master'
EOF
chown postgres. ${PGDATA} -R
chmod 700 ${PGDATA} -R
fi
gosu postgres postgres
Loading…
Cancel
Save