/pgadmin-container

A container of pgadmin pre-loaded with a database server group.

Primary LanguageShell

Quickstart

Copy the .sample.env file into a new .env file,

cp .sample.env .env

The .env file configures environment variables necessary for this project to work. For more information on the pgadmin environment variables, see here. For more information on the postgres environment variables, see here

In order for the application cluster to work, you will need to adjust POSTGRES_HOST (for containers, the host should be set equal to the name of the database service defined in the docker-compose.yml), POSTGRES_USER, POSTGRES_PASSWORD, PGADMIN_DEFAULT_USER, PGADMIN_DEFAULT_EMAIL and for each application whose database server you want to be able to see in pgadmin, you will need to adjust _DB_NAME (name of database), _DB_USER (user with permissions to access database) and _DB_PASSWORD (the password for the user just defined) variables. You can create more application database connections by adding them to the .env file and then adding those environment variables to the arrays defined in the BASH entrypoint script entrypoint.sh. Specifically, add your newly created database variables to lines 11 - 13,

dbs=($FIRST_DB_NAME $SECOND_DB_NAME $THIRD_DB_NAME)
users=($FIRST_DB_USER $SECOND_DB_USER $THIRD_DB_USER)
passwords=($FIRST_DB_PASSWORD $SECOND_DB_PASSWORD $THIRD_DB_PASSWORD)

To start the application, from the project root execute,

docker-compose up -d

A pgadmin server will then be available at localhost:5050. You will need to login with the credentials defined in the PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD. If you can't login with the username/password combo defined in the .env file, then you may need to delete the pgadmin volume and recreate it. See the following stack for more information

The database credentials in the environment variables are injected into PGPASSFILE credential fil, which is turn is injected into the PGADMIN_SERVER_JSON_FILE server configuration. After logging in with the PGADMIN_DEFAULT_USER and PGADMIN_DEFAULT_EMAIL, you should not need to log into the databases themselves. For this reason, be extremely careful with deploying this application. This setup is solely for ease of local development. Do not use this configuration in production without changing the PGPASSFILE injection process.

Useful Links

Postgres

PGAdmin

BASH