Skip to content

Commit

Permalink
feat(dev): add pgAdmin to local dev env (#144)
Browse files Browse the repository at this point in the history
Additions and Changes:
- add pgAdmin to docker-compose.yaml (incl. mounts)
- preconfigure pgAdmin DB server
- add tem. files to gitignore
- update README.md
- update Taskfile tasks for linux and macos
- update env.* environment files
- Match Postgresql version to the version of the Helm chart (14.5)
  • Loading branch information
pmoscode authored Nov 23, 2023
1 parent 6fd22a0 commit d7f2bbe
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ dev-assets/env-files/env.local
dev-assets/env-files/env.docker
dev-assets/env-files/env.environment
dev-assets/docker-environment/postgres/db.sh
dev-assets/docker-environment/pgAdmin/servers.json
dev-assets/docker-environment/pgAdmin/storage/*

.java-version

Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,27 @@ When you just run `task` without parameters, you will see all tasks available.
5. Click on "Authorize" and "close"
6. MIW is up and running

### pgAdmin

This local environment contains [pgAdmin](https://www.pgadmin.org/), which is also started (default: http://localhost:8888).
The default login is:

```
user: [email protected] (you can change it in the env.* files)
password: the one you set for "POSTGRES_PASSWORD" in the env.* files
```

#### DB connection password

When you log in into pgAdmin, the local Postgresql server is already configured.
But you will be asked to enter the DB password on the first time you connect to the DB.
(password: POSTGRES_PASSWORD in the env.* files)

#### Storage folder

The storage folder of pgAdmin is mounted to `dev-assets/docker-environment/pgAdmin/storage/`.
For example, You can save DB backups there, so you can access them on your local machine.

# End Users

See OpenAPI documentation, which is automatically created from the source and available on each deployment at
Expand Down Expand Up @@ -344,4 +365,4 @@ See [Docker-hub-notice.md](./Docker-hub-notice.md)

We would like to give credit to these projects, which we use in our project.

[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
24 changes: 22 additions & 2 deletions dev-assets/docker-environment/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
- miw-net

postgres:
image: postgres:15.3-alpine3.18
image: postgres:14.5-alpine3.16
volumes:
- postgres_data:/var/lib/postgresql/data
- ./postgres/db.sh:/docker-entrypoint-initdb.d/init-database.sh
Expand Down Expand Up @@ -63,10 +63,30 @@ services:
networks:
- miw-net

pgadmin:
image: dpage/pgadmin4
ports:
- "8888:80"
user: root # If removed, the storage mount won't work
env_file:
- ../env-files/env.$DEV_ENVIRONMENT
environment:
PGADMIN_DISABLE_POSTFIX: true
volumes:
- pgadmin_data:/var/lib/pgadmin
- ./pgAdmin/servers.json:/pgadmin4/servers.json
- ./pgAdmin/storage/:/var/lib/pgadmin/storage/pg_admin.com/
depends_on:
- postgres
networks:
- miw-net

volumes:
postgres_data:
driver: local
pgadmin_data:
driver: local

networks:
miw-net:
name: miw-net
name: miw-net
22 changes: 22 additions & 0 deletions dev-assets/docker-environment/pgAdmin/servers.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"Servers": {
"1": {
"Name": "Local",
"Group": "Servers",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "postgres",
"Username": "$POSTGRES_USER",
"UseSSHTunnel": 0,
"TunnelPort": "22",
"TunnelAuthentication": 0,
"KerberosAuthentication": false,
"ConnectionParameters": {
"sslmode": "prefer",
"connect_timeout": 10,
"sslcert": "<STORAGE_DIR>/.postgresql/postgresql.crt",
"sslkey": "<STORAGE_DIR>/.postgresql/postgresql.key"
}
}
}
}
22 changes: 22 additions & 0 deletions dev-assets/docker-environment/pgAdmin/storage/.git-keep
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# /********************************************************************************
# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/
#

Is mounted as storage folder inside the pgAdmin container.
21 changes: 0 additions & 21 deletions dev-assets/docker-environment/postgres/init.sql

This file was deleted.

4 changes: 4 additions & 0 deletions dev-assets/env-files/env.docker.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ POSTGRES_DB_NAME_MIW=miw
POSTGRES_USERNAME_MIW=miw_user
POSTGRES_PASSWORD_MIW=

# Docker: pgAdmin config
[email protected]

# Docker: Keycloak config
KEYCLOAK_MIW_PUBLIC_CLIENT=miw_public
DB_DATABASE=keycloak
Expand Down Expand Up @@ -45,5 +48,6 @@ DB_USER=${POSTGRES_USER}
DB_NAME=${POSTGRES_DB_NAME_MIW}
DB_USER_NAME=${POSTGRES_USERNAME_MIW}
DB_PASSWORD=${POSTGRES_PASSWORD_MIW}
PGADMIN_DEFAULT_PASSWORD=${POSTGRES_PASSWORD}
ORG_GRADLE_PROJECT_githubUserName=${GITHUB_USERNAME}
ORG_GRADLE_PROJECT_githubToken=${GITHUB_TOKEN}
4 changes: 4 additions & 0 deletions dev-assets/env-files/env.local.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ POSTGRES_DB_NAME_MIW=miw
POSTGRES_USERNAME_MIW=miw_user
POSTGRES_PASSWORD_MIW=

# Docker: pgAdmin config
[email protected]

# Docker: Keycloak config
KEYCLOAK_MIW_PUBLIC_CLIENT=miw_public
DB_DATABASE=keycloak
Expand Down Expand Up @@ -45,5 +48,6 @@ DB_USER=${POSTGRES_USER}
DB_NAME=${POSTGRES_DB_NAME_MIW}
DB_USER_NAME=${POSTGRES_USERNAME_MIW}
DB_PASSWORD=${POSTGRES_PASSWORD_MIW}
PGADMIN_DEFAULT_PASSWORD=${POSTGRES_PASSWORD}
ORG_GRADLE_PROJECT_githubUserName=${GITHUB_USERNAME}
ORG_GRADLE_PROJECT_githubToken=${GITHUB_TOKEN}
6 changes: 4 additions & 2 deletions dev-assets/tasks/darwin/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ tasks:
ignore_error: true
vars:
OPTIONS: '{{ default "" .OPTIONS }}'
CONTAINERS: '{{ default "postgres keycloak" .CONTAINERS }}'
CONTAINERS: '{{ default "postgres keycloak pgadmin" .CONTAINERS }}'
cmds:
- cat postgres/db.sh.tpl | envsubst > postgres/db.sh
- cat pgAdmin/servers.json.tpl | envsubst > pgAdmin/servers.json
- chmod +x postgres/db.sh
- "docker compose up {{.OPTIONS}} {{.CONTAINERS}}"

Expand All @@ -43,9 +44,10 @@ tasks:
dir: dev-assets/docker-environment
cmds:
- docker compose down
- cmd: docker volume remove docker-environment_postgres_data
- cmd: docker volume remove docker-environment_postgres_data docker-environment_pgadmin_data
ignore_error: true
- rm -f postgres/db.sh
- rm -f pgAdmin/servers.json

start-app:
desc: Run the app in a container environment (including middleware aka Postgresql and Keycloak)
Expand Down
6 changes: 4 additions & 2 deletions dev-assets/tasks/linux/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ tasks:
ignore_error: true
vars:
OPTIONS: '{{ default "" .OPTIONS }}'
CONTAINERS: '{{ default "postgres keycloak" .CONTAINERS }}'
CONTAINERS: '{{ default "postgres keycloak pgadmin" .CONTAINERS }}'
cmds:
- cat postgres/db.sh.tpl | envsubst > postgres/db.sh
- cat pgAdmin/servers.json.tpl | envsubst > pgAdmin/servers.json
- chmod +x postgres/db.sh
- "docker compose up {{.OPTIONS}} {{.CONTAINERS}}"

Expand All @@ -43,9 +44,10 @@ tasks:
dir: dev-assets/docker-environment
cmds:
- docker compose down
- cmd: docker volume remove docker-environment_postgres_data
- cmd: docker volume remove docker-environment_postgres_data docker-environment_pgadmin_data
ignore_error: true
- rm -f postgres/db.sh
- rm -f pgAdmin/servers.json

start-app:
desc: Run the app in a container environment (including middleware aka Postgresql and Keycloak)
Expand Down

0 comments on commit d7f2bbe

Please sign in to comment.