diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index 0f0649e..14bd668 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -27,6 +27,6 @@ EOF echo "Syncing flavors..." python manage.py sync_flavors -# Start the server -echo "Starting server..." -python manage.py runserver 0.0.0.0:8000 +# Start the server using Gunicorn +echo "Starting Gunicorn..." +exec gunicorn holy_backend.wsgi:application --bind 0.0.0.0:8000 --workers 3 diff --git a/backend/holy_backend/settings.py b/backend/holy_backend/settings.py index 84c3e38..2da25f1 100644 --- a/backend/holy_backend/settings.py +++ b/backend/holy_backend/settings.py @@ -33,6 +33,7 @@ ALLOWED_HOSTS = [host.strip() for host in ALLOWED_HOSTS_STRING.split(',')] # Application definition INSTALLED_APPS = [ + 'whitenoise.runserver_nostatic', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -128,7 +129,8 @@ USE_TZ = True STATIC_URL = 'static/' STATIC_ROOT = BASE_DIR / 'staticfiles' -STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' +WHITENOISE_INDEX_PAGE = True MEDIA_URL = 'media/' MEDIA_ROOT = BASE_DIR / 'media' @@ -136,6 +138,7 @@ MEDIA_ROOT = BASE_DIR / 'media' # --- Reverse Proxy Configuration --- # These settings are crucial for running behind a proxy like Traefik USE_X_FORWARDED_HOST = True +USE_X_FORWARDED_PORT = True SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Read CSRF trusted origins from environment variable diff --git a/backend/requirements.txt b/backend/requirements.txt index 61c84df..467e4a2 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -6,3 +6,4 @@ markdown>=3.5 Pillow>=10.2.0 drf-spectacular>=0.27.0 whitenoise>=6.6.0 +gunicorn>=21.2.0