From 79703061057b43d82b573b2c6d86b89cac363ac2 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sat, 27 Jan 2018 14:44:44 +0100 Subject: [PATCH] Make a proper data mount for Postgres --- postgres.sh | 16 ++++++++-------- postgres/etc/init.d/postgres | 2 +- postgres/srv/postgres/{ => data}/pg_hba.conf | 0 postgres/srv/postgres/{ => data}/postgresql.conf | 0 4 files changed, 9 insertions(+), 9 deletions(-) rename postgres/srv/postgres/{ => data}/pg_hba.conf (100%) rename postgres/srv/postgres/{ => data}/postgresql.conf (100%) diff --git a/postgres.sh b/postgres.sh index 31a95a9..a860652 100755 --- a/postgres.sh +++ b/postgres.sh @@ -6,19 +6,19 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/postgres docker build -t postgres ${SOURCE_DIR} # Create Postgres instance -mkdir /srv/postgres -chown -R 5432:5432 /srv/postgres -chmod 700 /srv/postgres -docker run --rm --name postgres -h postgres -v /srv/postgres:/var/lib/postgresql postgres initdb -D /var/lib/postgresql +mkdir -p /srv/postgres/data +chown -R 5432:5432 /srv/postgres/data +chmod 700 /srv/postgres/data +docker run --rm --name postgres -h postgres -v /srv/postgres/data:/var/lib/postgresql postgres initdb -D /var/lib/postgresql # Configure Postgres -cp ${SOURCE_DIR}/srv/postgres/postgresql.conf /srv/postgres/postgresql.conf -cp ${SOURCE_DIR}/srv/postgres/pg_hba.conf /srv/postgres/pg_hba.conf +cp ${SOURCE_DIR}/srv/postgres/data/postgresql.conf /srv/postgres/data/postgresql.conf +cp ${SOURCE_DIR}/srv/postgres/data/pg_hba.conf /srv/postgres/data/pg_hba.conf # Enable query logging. Only if the DEBUG environment variable is set if [ ${DEBUG:-0} -eq 1 ]; then - sed -i 's/^#log_destination/log_destination/' /srv/postgres/postgresql.conf - sed -i 's/^#log_statement/log_statement/' /srv/postgres/postgresql.conf + sed -i 's/^#log_destination/log_destination/' /srv/postgres/data/postgresql.conf + sed -i 's/^#log_statement/log_statement/' /srv/postgres/data/postgresql.conf fi # Configure Postgres service diff --git a/postgres/etc/init.d/postgres b/postgres/etc/init.d/postgres index 4d87135..e739508 100755 --- a/postgres/etc/init.d/postgres +++ b/postgres/etc/init.d/postgres @@ -11,7 +11,7 @@ start() { /usr/bin/docker run -d --rm \ --name postgres \ -h postgres \ - -v /srv/postgres:/var/lib/postgresql \ + -v /srv/postgres/data:/var/lib/postgresql \ postgres } diff --git a/postgres/srv/postgres/pg_hba.conf b/postgres/srv/postgres/data/pg_hba.conf similarity index 100% rename from postgres/srv/postgres/pg_hba.conf rename to postgres/srv/postgres/data/pg_hba.conf diff --git a/postgres/srv/postgres/postgresql.conf b/postgres/srv/postgres/data/postgresql.conf similarity index 100% rename from postgres/srv/postgres/postgresql.conf rename to postgres/srv/postgres/data/postgresql.conf