From 6620932371d57e2d88f089b2356529af93742c7f Mon Sep 17 00:00:00 2001 From: Lebaud Antoine Date: Thu, 25 Jan 2024 17:11:14 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(project)=20run=20production=20imag?= =?UTF-8?q?e=20locally=20with=20docker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The local deployment of the Production image through docker-compose was failing due to issues in the Django configurations, influenced by Joanie. The bug stemmed from a dependency on a development-specific package (drf-spectacular-sidecar) while attempting to run the application in production mode. Changes Made: - Introduced new Django settings for local demo environments. - Uncommented the nginx configuration to address the production image deployment issues. --- docker-compose.yml | 4 ++-- docker/files/etc/nginx/conf.d/default.conf | 12 ++++++------ src/backend/people/settings.py | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8ad3a5c..b084d4c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,7 +66,7 @@ services: user: ${DOCKER_USER:-1000} image: people:production environment: - - DJANGO_CONFIGURATION=ContinuousIntegration + - DJANGO_CONFIGURATION=Demo env_file: - env.d/development/common - env.d/development/postgresql @@ -81,7 +81,7 @@ services: image: people:production command: ["celery", "-A", "people.celery_app", "worker", "-l", "INFO"] environment: - - DJANGO_CONFIGURATION=ContinuousIntegration + - DJANGO_CONFIGURATION=Demo env_file: - env.d/development/common - env.d/development/postgresql diff --git a/docker/files/etc/nginx/conf.d/default.conf b/docker/files/etc/nginx/conf.d/default.conf index a90590d..656bb28 100644 --- a/docker/files/etc/nginx/conf.d/default.conf +++ b/docker/files/etc/nginx/conf.d/default.conf @@ -8,12 +8,12 @@ server { alias /data/media; } - # location / { - # proxy_pass http://app:8000; - # proxy_set_header Host $host; - # proxy_set_header X-Real-IP $remote_addr; - # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # } + location / { + proxy_pass http://app:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } } server { diff --git a/src/backend/people/settings.py b/src/backend/people/settings.py index 3b1155d..2f5e19a 100755 --- a/src/backend/people/settings.py +++ b/src/backend/people/settings.py @@ -522,3 +522,22 @@ class PreProduction(Production): nota bene: it should inherit from the Production environment. """ + + +class Demo(Production): + """ + Demonstration environment settings + + nota bene: it should inherit from the Production environment. + """ + + CSRF_TRUSTED_ORIGINS = ["http://localhost:8082"] + + STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", + }, + }