Skip to content

Commit

Permalink
made sure that the DB_USER_NAME is configurable in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed May 10, 2024
1 parent 2fe6598 commit 8de8042
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ENVIRONMENT=dev
DB_NAME=campus_db
DB_ROOT_PASSWORD=secret_root_password
DB_USER_PASSWORD=secret_root_password
DB_USER_NAME=root
DB_PORT=3306

SENTRY_DSN=
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ Additionally, docker creates the volume `campus-db-data` to persist the data of
### Environment Variables
The following environment variables need to be set for the server to work properly:
* [REQUIRED] `DB_NAME`: The name of the database to use.
* [REQUIRED] `DB_ROOT_PASSWORD`: The password of the root user.
* [REQUIRED] `DB_USER_PASSWORD`: The password of the user.
* [OPTIONAL] `DB_USER_NAME`: Name of the user to connect as. Defaults to `root`.
* [OPTIONAL] `DB_PORT`: The port of the database server. Defaults to `3306`.
* [OPTIONAL] `SENTRY_DSN`: The Sentry [Data Source Name](https://sentry-docs-git-patch-1.sentry.dev/product/sentry-basics/dsn-explainer/) for reporting issues and crashes.
* [OPTIONAL] `OMDB_API_KEY`: The key to get more information for tu-film movies from [omdbapi](https://omdbapi.com/). See [omdbapi](https://omdbapi.com/apikey.aspx) for a key.
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- "50051:50051"
environment:
- ENVIRONMENT=${ENVIRONMENT:-dev}
- DB_DSN=root:${DB_ROOT_PASSWORD}@tcp(db:${DB_PORT:-3306})/${DB_NAME}?charset=utf8mb4&parseTime=True&loc=Local
- DB_DSN=${DB_USER_NAME:-root}:${DB_USER_PASSWORD}@tcp(db:${DB_PORT:-3306})/${DB_NAME}?charset=utf8mb4&parseTime=True&loc=Local
- DB_NAME=${DB_NAME}
- SENTRY_DSN=${SENTRY_DSN}
- OMDB_API_KEY=${OMDB_API_KEY}
Expand All @@ -32,7 +32,7 @@ services:
ports:
- "${DB_PORT:-3306}:3306"
environment:
- MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
- MARIADB_ROOT_PASSWORD=${DB_USER_PASSWORD}
- MARIADB_DATABASE=${DB_NAME}
- MARIADB_CHARACTER_SET=utf8mb4
- MARIADB_COLLATE=utf8mb4_unicode_ci
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ services:
db:
container_name: cloudsql-proxy
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.5.0
command: tum-app-422909:europe-west1:tum-app-backend --credentials-file=/secrets/cloudsql/credentials.json --address 0.0.0.0 --port 3306
command: tum-app-422909:europe-west1:tum-app-backend --credentials-file=/secrets/cloudsql/credentials.json --address 0.0.0.0 --port ${DB_PORT:-3306}
networks:
- traefik_traefik
expose:
- "3306"
- "${DB_PORT:-3306}"
volumes:
- /root/credentials/backend-gcp-cloudsql-credentials.json:/secrets/cloudsql/credentials.json

Expand All @@ -31,7 +31,7 @@ services:
- "50051"
environment:
- ENVIRONMENT=${ENVIRONMENT:-dev}
- DB_DSN=root:${DB_ROOT_PASSWORD}@tcp(db:3306)/${DB_NAME}?charset=utf8mb4&parseTime=True&loc=Local
- DB_DSN=${DB_USER_NAME:-root}:${DB_USER_PASSWORD}@tcp(db:${DB_PORT:-3306})/${DB_NAME}?charset=utf8mb4&parseTime=True&loc=Local
- DB_NAME=${DB_NAME}
- SENTRY_DSN=${SENTRY_DSN}
- OMDB_API_KEY=${OMDB_API_KEY}
Expand Down

0 comments on commit 8de8042

Please sign in to comment.