Added support for passing password using Docker Secret to Docker images. Fixes #7332

This commit is contained in:
Yogesh Mahajan 2022-06-15 11:07:56 +05:30 committed by Akshay Joshi
parent 48336fd7f4
commit 3297546e0a
3 changed files with 16 additions and 2 deletions

View File

@ -52,6 +52,14 @@ to login to pgAdmin. This variable is required and must be set at launch time.
This is the password used when setting up the initial administrator account to
login to pgAdmin. This variable is required and must be set at launch time.
**PGADMIN_DEFAULT_PASSWORD_FILE**
This is the password used when setting up the initial administrator account to
login to pgAdmin. This value should be set to *docker secret* in order to set
the password. This variable is supported in docker swarm environment or while creating
container with docker compose. PGADMIN_DEFAULT_PASSWORD or PGADMIN_DEFAULT_PASSWORD_FILE
variable is required and must be set at launch time.
**PGADMIN_DISABLE_POSTFIX**
*Default: <null>*

View File

@ -9,6 +9,7 @@ This release contains a number of bug fixes and new features since the release o
New features
************
| `Issue #7332 <https://redmine.postgresql.org/issues/7332>`_ - Added support for passing password using Docker Secret to Docker images.
| `Issue #7351 <https://redmine.postgresql.org/issues/7351>`_ - Added the option 'Show template databases?' to display template databases regardless of the setting of 'Show system objects?'.
Housekeeping

View File

@ -36,8 +36,8 @@ EOF
fi
if [ ! -f /var/lib/pgadmin/pgadmin4.db ]; then
if [ -z "${PGADMIN_DEFAULT_EMAIL}" -o -z "${PGADMIN_DEFAULT_PASSWORD}" ]; then
echo 'You need to define the PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD environment variables.'
if ([ -z "${PGADMIN_DEFAULT_EMAIL}" ]) || ( [ -z "${PGADMIN_DEFAULT_PASSWORD}" ] && [ ! -n "${PGADMIN_DEFAULT_PASSWORD_FILE}" ] ); then
echo 'You need to define the PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD or PGADMIN_DEFAULT_PASSWORD_FILE environment variables.'
exit 1
fi
@ -47,6 +47,11 @@ if [ ! -f /var/lib/pgadmin/pgadmin4.db ]; then
exit 1
fi
# Read secret contents
if [ -n "${PGADMIN_DEFAULT_PASSWORD_FILE}" ]; then
export PGADMIN_DEFAULT_PASSWORD=$(cat ${PGADMIN_DEFAULT_PASSWORD_FILE})
fi
# Set the default username and password in a
# backwards compatible way
export PGADMIN_SETUP_EMAIL=${PGADMIN_DEFAULT_EMAIL}