From a36c09814b7640a24756da84cf50b0d8390dcc3b Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 3 Apr 2024 17:00:55 +0200 Subject: [PATCH 1/2] Made db host and so configurable --- brostar_api/settings.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/brostar_api/settings.py b/brostar_api/settings.py index ac16e4b..4b35079 100644 --- a/brostar_api/settings.py +++ b/brostar_api/settings.py @@ -1,7 +1,8 @@ import os from pathlib import Path -# Environment variables can get a default value from an .env file via docker-compose. +# Environment variables can get a value from an .env file via docker-compose. +# In development, you'll need to set the NENS_AUTH_* ones. FIELD_ENCRYPTION_KEY = os.getenv( "FIELD_ENCRYPTION_KEY", default="DUMMY-NEEDS-PROD-SETTING-Xgb1GczqZe909UMNc4=" ) @@ -13,6 +14,9 @@ NENS_AUTH_CLIENT_ID = os.getenv("NENS_AUTH_CLIENT_ID") NENS_AUTH_CLIENT_SECRET = os.getenv("NENS_AUTH_CLIENT_SECRET") DEBUG_ENV = os.getenv("DEBUG", default="true") +DATABASE_HOST=os.getenv("DATABASE_HOST", "db") +DATABASE_USER=os.getenv("DATABASE_USER", "brostar") +DATABASE_PASSWORD=os.getenv("DATABASE_PASSWORD", "brostar") # Convert the environment variable (which is a string) to a boolean. DEBUG = DEBUG_ENV.lower() == "true" # True is the default @@ -121,9 +125,9 @@ "default": { "ENGINE": "django.db.backends.postgresql", "NAME": "brostar", - "USER": "brostar", - "PASSWORD": "brostar", - "HOST": "db", + "USER": DATABASE_USER, + "PASSWORD": DATABASE_PASSWORD, + "HOST": DATABASE_HOST, } } From 4f235c62e300b72526cbfd080605520bfd7e1e7a Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 3 Apr 2024 17:03:01 +0200 Subject: [PATCH 2/2] ruff --- brostar_api/settings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brostar_api/settings.py b/brostar_api/settings.py index 4b35079..c6ee066 100644 --- a/brostar_api/settings.py +++ b/brostar_api/settings.py @@ -14,9 +14,9 @@ NENS_AUTH_CLIENT_ID = os.getenv("NENS_AUTH_CLIENT_ID") NENS_AUTH_CLIENT_SECRET = os.getenv("NENS_AUTH_CLIENT_SECRET") DEBUG_ENV = os.getenv("DEBUG", default="true") -DATABASE_HOST=os.getenv("DATABASE_HOST", "db") -DATABASE_USER=os.getenv("DATABASE_USER", "brostar") -DATABASE_PASSWORD=os.getenv("DATABASE_PASSWORD", "brostar") +DATABASE_HOST = os.getenv("DATABASE_HOST", "db") +DATABASE_USER = os.getenv("DATABASE_USER", "brostar") +DATABASE_PASSWORD = os.getenv("DATABASE_PASSWORD", "brostar") # Convert the environment variable (which is a string) to a boolean. DEBUG = DEBUG_ENV.lower() == "true" # True is the default