From 362e9792e9bbff77e443c59c4c402266c5f11ddb Mon Sep 17 00:00:00 2001 From: Thomas Schwery Date: Sun, 6 Mar 2022 13:02:18 +0100 Subject: [PATCH] chore: Prepare settings for production --- djangotea/settings.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/djangotea/settings.py b/djangotea/settings.py index 242df97..7fa0d36 100644 --- a/djangotea/settings.py +++ b/djangotea/settings.py @@ -10,23 +10,24 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +production = os.environ.get('PRODUCTION', False) == 'true' -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ +if production: + SECRET_KEY = os.environ.get('SECRET_KEY') +else: + SECRET_KEY = 'django-insecure-de-2*zq9g3v5!bjit%^hh5=je_a6mk!sc4)r@+a3ubd*e^7x1a' -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-de-2*zq9g3v5!bjit%^hh5=je_a6mk!sc4)r@+a3ubd*e^7x1a' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] +DEBUG = not production +ALLOWED_HOSTS = [ + '*', +] # Application definition @@ -78,8 +79,12 @@ WSGI_APPLICATION = 'djangotea.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + "ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"), + "NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")), + "USER": os.environ.get("SQL_USER", "user"), + "PASSWORD": os.environ.get("SQL_PASSWORD", "password"), + "HOST": os.environ.get("SQL_HOST", "localhost"), + "PORT": os.environ.get("SQL_PORT", "5432"), } }