Skip to content

Commit ea130f5

Browse files
committed
Update settings and dependencies for production docker
1 parent 028583c commit ea130f5

4 files changed

Lines changed: 27 additions & 9 deletions

File tree

Dockerfile.dockerignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Don't include react app in Django container
2-
/registration-frontend-react
3-
41
.env
52
/docker-compose.yaml
63
/compose.yaml

config/settings.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
https://docs.djangoproject.com/en/5.0/ref/settings/
1111
"""
1212

13+
import os
1314
from pathlib import Path
1415

1516
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -20,17 +21,20 @@
2021
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
2122

2223
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = "django-insecure-w^mv=r_(x-se8p#@i*dxfu1^*8$fci+116it+fkj*nx!o2h*r1"
24-
24+
SECRET_KEY = os.getenv(
25+
"DJANGO_SECRET_KEY",
26+
"django-insecure-w^mv=r_(x-se8p#@i*dxfu1^*8$fci+116it+fkj*nx!o2h*r1",
27+
)
2528
# SECURITY WARNING: don't run with debug turned on in production!
26-
DEBUG = True
29+
DEBUG = os.getenv("DJANGO_DEBUG", "False").lower() == "true"
2730

28-
ALLOWED_HOSTS = ["*"]
31+
ALLOWED_HOSTS = os.getenv("DJANGO_HOSTS", "*").split(",")
2932

3033

3134
# Application definition
3235

3336
INSTALLED_APPS = [
37+
"daphne",
3438
"django.contrib.admin",
3539
"django.contrib.auth",
3640
"django.contrib.contenttypes",
@@ -71,15 +75,20 @@
7175
]
7276

7377
WSGI_APPLICATION = "config.wsgi.application"
78+
ASGI_APPLICATION = "config.asgi.application"
7479

7580

7681
# Database
7782
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
7883

7984
DATABASES = {
8085
"default": {
81-
"ENGINE": "django.db.backends.sqlite3",
82-
"NAME": BASE_DIR / "db.sqlite3",
86+
"ENGINE": os.getenv("DJANGO_DATABASE_ENGINE", "django.db.backends.sqlite3"),
87+
"HOST": os.getenv("DJANGO_DATABASE_HOST"),
88+
"PORT": os.getenv("DJANGO_DATABASE_PORT", 5432),
89+
"NAME": os.getenv("POSTGRES_DB", BASE_DIR / "db.sqlite3"),
90+
"USER": os.getenv("POSTGRES_USER"),
91+
"PASSWORD": os.getenv("POSTGRES_PASSWORD"),
8392
}
8493
}
8594

@@ -119,6 +128,7 @@
119128
# https://docs.djangoproject.com/en/5.0/howto/static-files/
120129

121130
STATIC_URL = "static/"
131+
STATIC_ROOT = os.getenv("DJANGO_STATIC_ROOT")
122132

123133
# Default primary key field type
124134
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

requirements-dev.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-r requirements.txt
2+
3+
black==24.10.0
4+
pytest==8.3.3
5+
mypy==1.13.0
6+
django-stubs[compatible-mypy]==5.1.1
7+
# TODO: Change djangorestframework-stubs to pypi release
8+
# Django rest framework stubs does not yet have a mypy 1.13 compatible release
9+
djangorestframework-stubs[compatible-mypy] @ git+https://github.com/typeddjango/djangorestframework-stubs.git@93b4ffe1441f43a646138ad302144a849bc6ecc0

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
Django[all]==5.1.3
22
django-urlconfchecks==0.11.0 # TODO: Add to CI
3+
daphne==4.1.2
4+
psycopg2-binary==2.9.10

0 commit comments

Comments
 (0)