From 7e434d144b6c47ff974911fe35ace33aaa899d86 Mon Sep 17 00:00:00 2001 From: Ludovic Cleroux Date: Fri, 27 Oct 2023 14:50:54 +0200 Subject: [PATCH] ROX-19980 fix --- image/db/rhel/Dockerfile.slim | 2 +- image/db/rhel/scripts/custom-entrypoint.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/image/db/rhel/Dockerfile.slim b/image/db/rhel/Dockerfile.slim index f3ec9628c..5be32572d 100644 --- a/image/db/rhel/Dockerfile.slim +++ b/image/db/rhel/Dockerfile.slim @@ -36,7 +36,7 @@ RUN curl -sSLf https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-${ groupadd -g 70 postgres && \ adduser postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh && \ microdnf install \ - ca-certificates libicu systemd-sysv glibc-locale-source glibc-langpack-en \ + ca-certificates tar libicu systemd-sysv glibc-locale-source glibc-langpack-en \ postgresql12-server && \ # The removal of /usr/share/zoneinfo from UBI minimal images is intentional. # After building the image, the image is reduced in size as much as possible, diff --git a/image/db/rhel/scripts/custom-entrypoint.sh b/image/db/rhel/scripts/custom-entrypoint.sh index 1bb1b2a1c..3fa66955f 100755 --- a/image/db/rhel/scripts/custom-entrypoint.sh +++ b/image/db/rhel/scripts/custom-entrypoint.sh @@ -38,7 +38,11 @@ if [ ! -d "/var/lib/postgresql/data/pgdata" ]; then echo "Renaming postgres user if necessary..." if [ -n "$POSTGRES_USER" ]; then if [ "$POSTGRES_USER" != "postgres" ]; then - PGPASSWORD="$POSTGRES_PASSWORD" psql -c "ALTER USER postgres RENAME TO $POSTGRES_USER;" + if [ -n "$POSTGRES_PASSWORD" ]; then + PGPASSWORD="$POSTGRES_PASSWORD" psql -c "ALTER USER postgres RENAME TO $POSTGRES_USER;" + elif [ -n "$POSTGRES_PASSWORD_FILE" ]; then + PGPASSWORD="$(cat "$POSTGRES_PASSWORD_FILE")" psql -c "ALTER USER postgres RENAME TO $POSTGRES_USER;" + fi fi fi