1
0
mirror of https://github.com/docker-library/postgres.git synced 2025-07-28 10:42:06 +03:00

POSTGRES_INITDB_XLOGDIR to specify xlog log dir

Adds support for the POSTGRES_INITDB_XLOGDIR environment variable, which specifies where the postgres transaction log is stored.

For some use cases, being able to place the transaction log on a different volume is useful.

Existing support for providing flags via $POSTGRES_INITDB_ARGS is inadequate because of the need to create and chown/chmod the directory prior to running initdb.
This commit is contained in:
Daniel Dent
2016-11-19 23:32:41 -08:00
parent 7f792e7e4d
commit 89530f6020
11 changed files with 99 additions and 0 deletions

View File

@ -37,6 +37,15 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then
chown -R postgres /var/run/postgresql
chmod g+s /var/run/postgresql
# Create the transaction log directory before initdb is run (below) so the directory is owned by the correct user
file_env 'POSTGRES_INITDB_XLOGDIR'
if [ "$POSTGRES_INITDB_XLOGDIR" ]; then
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
chown -R postgres "$POSTGRES_INITDB_XLOGDIR"
export POSTGRES_INITDB_ARGS="$POSTGRES_INITDB_ARGS --xlogdir $POSTGRES_INITDB_XLOGDIR"
fi
exec gosu postgres "$BASH_SOURCE" "$@"
fi