Allow servers to be pre-loaded into container deployments. Fixes #3801

This commit is contained in:
Dave Page 2018-12-05 17:16:46 +00:00
parent 55402ec7d9
commit 1141930178
4 changed files with 130 additions and 2 deletions

View File

@ -0,0 +1,117 @@
.. _container_deployment:
**************************************
`Container Deployment`:index:
**************************************
pgAdmin can be deployed in a container using the image at:
https://hub.docker.com/r/dpage/pgadmin4/
Environment Variables
*********************
The container will accept the following variables at startup:
*PGADMIN_DEFAULT_EMAIL*
This is the email address 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*
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_ENABLE_TLS*
Default: <null>
If left un-set, the container will listen on port 80 for connections in plain
text. If set to any value, the container will listen on port 443 for TLS
connections.
When TLS is enabled, a certificate and key must be provided. Typically these
should be stored on the host file system and mounted from the container. The
expected paths are /certs/server.crt and /certs/server.key
*PGADMIN_LISTEN_PORT*
Default: 80 or 443 (if TLS is enabled)
Allows the port that the server listens on to be set to a specific value rather
than using the default.
*GUNICORN_THREADS*
Default: 25
Adjust the number of threads the Gunicorn server uses to handle incoming
requests. This should typically be left as-is, except in highly loaded systems
where it may be increased.
Mapped Files and Directories
****************************
The following files or directories can be mapped from the container onto the
host machine to allow configuration to be customised and shared between
instances:
*/var/lib/pgadmin*
This is the working directory in which pgAdmin stores session data, user files,
configuration files, and it's configuration database. Mapping this directory
onto the host machine gives you an easy way to maintain configuration between
invocations of the container.
*/pgadmin4/config_local.py*
This file can be used to override configuration settings in pgAdmin. Settings
found in config.py can be overridden with deployment specific values if
required.
*/pgadmin4/servers.json*
If this file is mapped, server definitions found in it will be loaded at launch
time. This allows connection information to be pre-loaded into the instance of
pgAdmin in the container.
*/certs/server.cert*
If TLS is enabled, this file will be used as the servers TLS certificate.
*/certs/server.key*
If TLS is enabled, this file will be used as the key file for the servers TLS
certificate.
Examples
********
Run a simple container over port 80:
.. code-block:: bash
docker pull dpage/pgadmin4
docker run -p 80:80 \
-e "PGADMIN_DEFAULT_EMAIL=user@domain.com" \
-e "PGADMIN_DEFAULT_PASSWORD=SuperSecret" \
-d dpage/pgadmin4
Run a TLS secured container using a shared config/storage directory in
/private/var/lib/pgadmin on the host, and servers pre-loaded from
/tmp/servers.json on the host:
.. code-block:: bash
docker pull dpage/pgadmin4
docker run -p 443:443 \
-v "/private/var/lib/pgadmin:/var/lib/pgadmin" \
-v "/path/to/certificate.cert:/certs/server.cert" \
-v "/path/to/certificate.key:/certs/server.key" \
-v "/tmp/servers.json:/servers.json" \
-e "PGADMIN_DEFAULT_EMAIL=user@domain.com" \
-e "PGADMIN_DEFAULT_PASSWORD=SuperSecret" \
-e "PGADMIN_ENABLE_TLS=True" \
-d dpage/pgadmin4

View File

@ -4,7 +4,11 @@
`pgAdmin Deployment`:index:
***************************
Pre-compiled and configured installation packages for pgAdmin 4 are available for a number of desktop environments; we recommend using an installer whenever possible. If you are interested in learning more about the project, or if a pgAdmin installer is not available for your environment, the pages listed below will provide detailed information about creating a custom deployment.
Pre-compiled and configured installation packages for pgAdmin 4 are available
for a number of desktop environments; we recommend using an installer whenever
possible. If you are interested in learning more about the project, or if a
pgAdmin installer is not available for your environment, the pages listed below
will provide detailed information about creating a custom deployment.
Contents:
@ -13,3 +17,4 @@ Contents:
desktop_deployment
server_deployment
container_deployment

View File

@ -10,6 +10,7 @@ This release contains a number of features and fixes reported since the release
Features
********
| `Bug #3801 <https://redmine.postgresql.org/issues/3801>`_ - Allow servers to be pre-loaded into container deployments.
Bug fixes
*********

View File

@ -14,6 +14,11 @@ if [ ! -f /var/lib/pgadmin/pgadmin4.db ]; then
# Initialize DB before starting Gunicorn
# Importing pgadmin4 (from this script) is enough
python run_pgadmin.py
# Pre-load any required servers
if [ -f /pgadmin4/servers.json ]; then
/usr/local/bin/python /pgadmin4/setup.py --load-servers /pgadmin4/servers.json --user ${PGADMIN_DEFAULT_EMAIL}
fi
fi
# Start Postfix to handle password resets etc.