From 7b631515f08f5f7ed9c3c400892977e93b994651 Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Mon, 16 Sep 2024 12:22:19 +0200 Subject: [PATCH] feat: Add DB GUI accessible from URL --- .env.template | 5 +++++ README.md | 14 ++++++++++++++ docker/dev/docker-compose.yml | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/.env.template b/.env.template index 0d36d9b9..586f3f66 100644 --- a/.env.template +++ b/.env.template @@ -18,3 +18,8 @@ APPLICATION_REDIS_HOST=127.0.0.1 # e2e tests are running in parallel, so we need a strict amount of workers, # so then we can dynamically create the same amount of DBs JEST_WORKERS_AMOUNT=4 + +# pgAdmin config +PGADMIN_DEFAULT_EMAIL=admin@admin.com +PGADMIN_DEFAULT_PASSWORD=password +PGADMIN_LISTEN_PORT=8001 diff --git a/README.md b/README.md index 0104d8c8..08bfc9d7 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,26 @@ Now it should be accessible under the port that you defined in the `.env.develop due to DB connection issues. It's a very rare case, but if this happens, _**simply run the command again**_. +### Additional services for local development + +#### pgAdmin (DB data viewer) + +There's a pgAdmin available under the port `8001`. You can modify configuration for email and password of the dashboard in the env file. On the first setup, after logging in on the dashboard you will see "Add new server". Click on it, give it whatever Name you want. + +Under the `Connection` tab you will need to fill a few fields: + +- Host name/address – `db` (postgres service name from `docker/dev/docker-compose.yml` file) +- Username – value from the `APPLICATION_DB_USERNAME` env variable +- Password - value from the `APPLICATION_DB_PASSWORD` env variable + ### Useful command for local development: 1. `npm run docker:dev:down` to stop containers. All the data will still be stored in the DB. 2. `npm run docker:dev:destroy` stops containers, and _**Completely destroys all the images, container and volumes**_. It means all the data will be erased from the DB. Useful when you want to test new migrations, or DB structure was damaged. 3. Use `docker:dev:run-in-container -- ` to run any command inside running docker container. For example `docker:dev:run-in-container -- npm run migrate:dev` to run migrations and `docker:dev:run-in-container -- npm run migrate:dev:undo` to undo them. +
+

### If you don't want to use Docker diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 3e106a19..aebb1a3f 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -26,6 +26,15 @@ services: volumes: ['redis_data:/data'] ports: ['6379:6379'] + pgadmin: + image: dpage/pgadmin4:8.11 + environment: + - PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL} + - PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD} + - PGADMIN_LISTEN_PORT=${PGADMIN_LISTEN_PORT} + ports: ['8001:8001'] + depends_on: ['db'] + volumes: db_data: redis_data: