Skip to content

Commit

Permalink
Add support for locale and encoding, fix #406
Browse files Browse the repository at this point in the history
  • Loading branch information
mscherer committed Jul 22, 2021
1 parent 70dc4d3 commit 5ce635f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/root/usr/share/container-scripts/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ initialization by passing `-e VAR=VALUE` to the Docker run command.
**`POSTGRESQL_ADMIN_PASSWORD`**
Password for the `postgres` admin account (optional)

The following environment variables are optional, and only used when the database is initialzed

**`POSTGRESQL_ENCODING`**
Database encoding. Default to UTF-8

**`POSTGRESQL_LOCALE`**
Database locale. Default to en_EN

Alternatively, the following options are related to migration scenario:

Expand Down
10 changes: 9 additions & 1 deletion src/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,15 @@ EOF
function create_users() {
if [[ ",$postinitdb_actions," = *,simple_db,* ]]; then
createuser "$POSTGRESQL_USER"
createdb --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
EXTRA_ARGS=""
if [ -v POSTGRESQL_ENCODING ]; then
EXTRA_ARGS="$EXTRA_ARGS -E $POSTGRESQL_ENCODING"
fi
if [ -v POSTGRESQL_LOCALE ]; then
EXTRA_ARGS="$EXTRA_ARGS -l $POSTGRESQL_LOCALE"
fi

createdb $EXTRA_ARGS --owner="$POSTGRESQL_USER" "$POSTGRESQL_DATABASE"
fi

if [ -v POSTGRESQL_MASTER_USER ]; then
Expand Down

0 comments on commit 5ce635f

Please sign in to comment.