Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for locale and encoding, fix #406 #416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 10/Dockerfile.c8s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/sclorg/s2i-core-c8s:c8s
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=10 \
POSTGRESQL_PREV_VERSION=9.6 \
Expand Down
2 changes: 2 additions & 0 deletions 10/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM rhscl/s2i-core-rhel7
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=10 \
POSTGRESQL_PREV_VERSION=9.6 \
Expand Down
2 changes: 2 additions & 0 deletions 10/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM ubi8/s2i-core
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=10 \
POSTGRESQL_PREV_VERSION=9.6 \
Expand Down
16 changes: 14 additions & 2 deletions 10/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ initdb_wrapper ()
# Initialize the database cluster with utf8 support enabled by default.
# This might affect performance, see:
# http://www.postgresql.org/docs/10/static/locale.html
LANG=${LANG:-en_US.utf8} "$@"
ENCODING=${POSTGRESQL_ENCODING:-UTF8}
LOCALE=${POSTGRESQL_LOCALE:-en_US}
if [ ${LOCALE} == "C" ] ; then LANG=C; fi
LANG=${LANG:-$LOCALE.$ENCODING} "$@" -E $ENCODING
}

function initialize_database() {
Expand Down Expand Up @@ -234,7 +237,16 @@ 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
2 changes: 2 additions & 0 deletions 12/Dockerfile.c8s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/sclorg/s2i-core-c8s:c8s
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=12 \
POSTGRESQL_PREV_VERSION=10 \
Expand Down
2 changes: 2 additions & 0 deletions 12/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/fedora/s2i-core:38
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV NAME=postgresql \
VERSION=0 \
Expand Down
2 changes: 2 additions & 0 deletions 12/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM rhscl/s2i-core-rhel7
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=12 \
POSTGRESQL_PREV_VERSION=10 \
Expand Down
2 changes: 2 additions & 0 deletions 12/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM ubi8/s2i-core
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=12 \
POSTGRESQL_PREV_VERSION=10 \
Expand Down
16 changes: 14 additions & 2 deletions 12/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ initdb_wrapper ()
# Initialize the database cluster with utf8 support enabled by default.
# This might affect performance, see:
# http://www.postgresql.org/docs/12/static/locale.html
LANG=${LANG:-en_US.utf8} "$@"
ENCODING=${POSTGRESQL_ENCODING:-UTF8}
LOCALE=${POSTGRESQL_LOCALE:-en_US}
if [ ${LOCALE} == "C" ] ; then LANG=C; fi
LANG=${LANG:-$LOCALE.$ENCODING} "$@" -E $ENCODING
}

function initialize_database() {
Expand Down Expand Up @@ -234,7 +237,16 @@ 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
2 changes: 2 additions & 0 deletions 13/Dockerfile.c8s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/sclorg/s2i-core-c8s:c8s
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=13 \
POSTGRESQL_PREV_VERSION=12 \
Expand Down
2 changes: 2 additions & 0 deletions 13/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/sclorg/s2i-core-c9s:c9s
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=13 \
POSTGRESQL_PREV_VERSION=12 \
Expand Down
2 changes: 2 additions & 0 deletions 13/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/fedora/s2i-core:38
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV NAME=postgresql \
VERSION=0 \
Expand Down
2 changes: 2 additions & 0 deletions 13/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM rhscl/s2i-core-rhel7
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=13 \
POSTGRESQL_PREV_VERSION=12 \
Expand Down
2 changes: 2 additions & 0 deletions 13/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM ubi8/s2i-core
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=13 \
POSTGRESQL_PREV_VERSION=12 \
Expand Down
2 changes: 2 additions & 0 deletions 13/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM ubi9/s2i-core
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=13 \
POSTGRESQL_PREV_VERSION=12 \
Expand Down
16 changes: 14 additions & 2 deletions 13/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ initdb_wrapper ()
# Initialize the database cluster with utf8 support enabled by default.
# This might affect performance, see:
# http://www.postgresql.org/docs/13/static/locale.html
LANG=${LANG:-en_US.utf8} "$@"
ENCODING=${POSTGRESQL_ENCODING:-UTF8}
LOCALE=${POSTGRESQL_LOCALE:-en_US}
if [ ${LOCALE} == "C" ] ; then LANG=C; fi
LANG=${LANG:-$LOCALE.$ENCODING} "$@" -E $ENCODING
}

function initialize_database() {
Expand Down Expand Up @@ -234,7 +237,16 @@ 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
2 changes: 2 additions & 0 deletions 14/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/fedora/s2i-core:38
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV NAME=postgresql \
VERSION=0 \
Expand Down
16 changes: 14 additions & 2 deletions 14/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ initdb_wrapper ()
# Initialize the database cluster with utf8 support enabled by default.
# This might affect performance, see:
# http://www.postgresql.org/docs/14/static/locale.html
LANG=${LANG:-en_US.utf8} "$@"
ENCODING=${POSTGRESQL_ENCODING:-UTF8}
LOCALE=${POSTGRESQL_LOCALE:-en_US}
if [ ${LOCALE} == "C" ] ; then LANG=C; fi
LANG=${LANG:-$LOCALE.$ENCODING} "$@" -E $ENCODING
}

function initialize_database() {
Expand Down Expand Up @@ -234,7 +237,16 @@ 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
2 changes: 2 additions & 0 deletions 15/Dockerfile.c8s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/sclorg/s2i-core-c8s:c8s
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=15 \
POSTGRESQL_PREV_VERSION=13 \
Expand Down
2 changes: 2 additions & 0 deletions 15/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/sclorg/s2i-core-c9s:c9s
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=15 \
POSTGRESQL_PREV_VERSION=13 \
Expand Down
2 changes: 2 additions & 0 deletions 15/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/fedora/s2i-core:38
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV NAME=postgresql \
VERSION=0 \
Expand Down
2 changes: 2 additions & 0 deletions 15/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM ubi8/s2i-core
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=15 \
POSTGRESQL_PREV_VERSION=13 \
Expand Down
2 changes: 2 additions & 0 deletions 15/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM ubi9/s2i-core
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION=15 \
POSTGRESQL_PREV_VERSION=13 \
Expand Down
16 changes: 14 additions & 2 deletions 15/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ initdb_wrapper ()
# Initialize the database cluster with utf8 support enabled by default.
# This might affect performance, see:
# http://www.postgresql.org/docs/15/static/locale.html
LANG=${LANG:-en_US.utf8} "$@"
ENCODING=${POSTGRESQL_ENCODING:-UTF8}
LOCALE=${POSTGRESQL_LOCALE:-en_US}
if [ ${LOCALE} == "C" ] ; then LANG=C; fi
LANG=${LANG:-$LOCALE.$ENCODING} "$@" -E $ENCODING
}

function initialize_database() {
Expand Down Expand Up @@ -234,7 +237,16 @@ 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
2 changes: 2 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM {{ spec.s2i_base }}
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV POSTGRESQL_VERSION={{ spec.version }} \
{% if spec.prod != "rhel8" or spec.prod != "rhel9" or spec.version == "10" %}
Expand Down
2 changes: 2 additions & 0 deletions src/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ FROM quay.io/fedora/s2i-core:38
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
# * $POSTGRESQL_ENCODING - Database encoding. Default to UTF8
# * $POSTGRESQL_LOCALE - Database locale. Default to en_US

ENV NAME=postgresql \
VERSION=0 \
Expand Down
16 changes: 14 additions & 2 deletions src/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ initdb_wrapper ()
# Initialize the database cluster with utf8 support enabled by default.
# This might affect performance, see:
# http://www.postgresql.org/docs/{{ spec.version }}/static/locale.html
LANG=${LANG:-en_US.utf8} "$@"
ENCODING=${POSTGRESQL_ENCODING:-UTF8}
LOCALE=${POSTGRESQL_LOCALE:-en_US}
if [ ${LOCALE} == "C" ] ; then LANG=C; fi
LANG=${LANG:-$LOCALE.$ENCODING} "$@" -E $ENCODING
}

function initialize_database() {
Expand Down Expand Up @@ -235,7 +238,16 @@ 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
Loading