Skip to content

Commit

Permalink
Merge pull request #132 from letehaha/feat/add-db-gui
Browse files Browse the repository at this point in the history
feat: Add DB GUI accessible from URL
  • Loading branch information
letehaha authored Sep 16, 2024
2 parents cb13649 + 7b63151 commit 45fb4d8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
[email protected]
PGADMIN_DEFAULT_PASSWORD=password
PGADMIN_LISTEN_PORT=8001
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- <some command>` 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.

<hr>
<hr>
<hr>

### If you don't want to use Docker
Expand Down
9 changes: 9 additions & 0 deletions docker/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

0 comments on commit 45fb4d8

Please sign in to comment.