diff --git a/.env b/.env index 3648159b..497bb608 100644 --- a/.env +++ b/.env @@ -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= diff --git a/README.md b/README.md index 5df5ce68..f892e183 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 5f3fb88e..f3d2970e 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -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} @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 0aa56024..08ace856 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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}