Skip to content

Commit

Permalink
update default locale + some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
barcus committed Mar 18, 2022
1 parent 5b8786f commit 98c3498
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ FROM postgres:14-bullseye
LABEL maintainer="[email protected]"

ARG PG_NEW
ENV PG_ADMIN "root"

RUN mkdir /var/log/postgres

RUN apt-get update \
&& apt-get install -y sudo

RUN adduser postgres sudo
RUN echo '%postgres ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

WORKDIR /var/log/postgres
RUN mkdir -p /var/log/postgresql
WORKDIR /var/log/postgresql

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
Expand Down
10 changes: 3 additions & 7 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,14 @@ if [ "$(id -u)" = '0' ] ;then
exec gosu postgres "$BASH_SOURCE" "$@"
fi

if [ "$1" = 'pg_upgrade' -a "$(id -u)" = '0' ] ;then
exec gosu postgres "$BASH_SOURCE" "$@"
fi

# Collect information from PG_OLD
# Start DB PG_OLD
eval "${PGBINOLD}/pg_ctl -D ${PGDATAOLD} -l logfile start"
# Wait for init
sleep 3
# Get default DB encoding and local
ENCODING=$(eval "${PGBINNEW}/psql -t $PGUSER -c 'SHOW SERVER_ENCODING'")
LOCALE=$(eval "${PGBINNEW}/psql -t $PGUSER -c 'SHOW LC_COLLATE'")
ENCODING=$(eval "${PGBINOLD}/psql -t $PGUSER -c 'SHOW SERVER_ENCODING'")
LOCALE=$(eval "${PGBINOLD}/psql -t $PGUSER -c 'SHOW LC_COLLATE'")
export ENCODING=$(echo ${ENCODING}| xargs)
export LOCALE=$(echo ${LOCALE}| xargs)
# Stop DB PG_OLD
Expand All @@ -67,7 +63,7 @@ eval "${PGBINOLD}/pg_ctl -D ${PGDATAOLD} -l logfile stop"
# Init DB PG_NEW
[ -z "${ENCODING}" ] && ENCODING="SQL_ASCII"
[ -z "${LOCALE}" ] && LOCALE="en_US.utf8"
eval "${PGBINNEW}/initdb --user=${PGUSER} --pgdata=${PGDATANEW} --encoding=${ENCODING} --lc-collate=${LOCALE} --lc-ctype=${LOCALE}"
eval "${PGBINNEW}/initdb --username=${PGUSER} --pgdata=${PGDATANEW} --encoding=${ENCODING} --lc-collate=${LOCALE} --lc-ctype=${LOCALE}"

if [ "$1" = 'pg_upgrade' ] ;then
# Upgrade DB PG_OLD into PG_NEW
Expand Down

0 comments on commit 98c3498

Please sign in to comment.