Skip to content

Commit c2b722d

Browse files
committed
set unique PGDATA for each standby server
1 parent 247c7cb commit c2b722d

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

db/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ ARG mode
1111
# with a data directory that is empty
1212
# See https://docs.docker.com/samples/library/postgres/#initialization-scripts
1313
COPY ./pg.$mode.setup.sh /docker-entrypoint-initdb.d/pg.$mode.setup.sh
14+
15+
# Set PGDATA immediate after shebang
16+
RUN set -ex \
17+
&& sed -i "2s/^/PGDATA=\/var\/lib\/postgresql\/data\/$mode\/"'$HOSTNAME'"\n\n/" /usr/local/bin/docker-entrypoint.sh

db/pg.master.env

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# database
2-
PGDATA=/var/lib/postgresql/data/pgdata_master
32
POSTGRES_USER=devops
43
POSTGRES_PASSWORD=devops
54
POSTGRES_DB=postgres

db/pg.standby.env

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# database
2-
PGDATA=/var/lib/postgresql/data/pgdata_standby
32
PG_MASTER_HOST=db.master
43
PG_MASTER_PORT=5432
54
PG_MASTER_REP_USER=devops_rep

0 commit comments

Comments
 (0)