From 7117e1a54d1c59863613eb4093809372584c2220 Mon Sep 17 00:00:00 2001 From: Matteo Date: Tue, 14 Jan 2025 15:11:26 +0100 Subject: [PATCH] added whitenoise for static files --- bookinghub/settings.py | 2 ++ entrypoint.sh | 5 ++++- requirements.txt | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bookinghub/settings.py b/bookinghub/settings.py index 68ced16..ef446b4 100644 --- a/bookinghub/settings.py +++ b/bookinghub/settings.py @@ -53,6 +53,7 @@ "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "corsheaders.middleware.CorsMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleware", ] CSRF_TRUSTED_ORIGINS = [ @@ -161,6 +162,7 @@ STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] +STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" # Default primary key field type # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field diff --git a/entrypoint.sh b/entrypoint.sh index 1e7bfe1..d44cf37 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,8 +6,11 @@ python manage.py wait_for_db # Eseguo le migrazioni python manage.py migrate +# Eseguo il collectstatic +python manage.py collectstatic --noinput + # Eseguo il comando di gestione personalizzato python manage.py create_superuser_if_not_exists # Avvio il server -python manage.py runserver 0.0.0.0:8000 +exec gunicorn bookinghub.wsgi:application --workers 4 --threads 2 --bind 0.0.0.0:8000 diff --git a/requirements.txt b/requirements.txt index 22af5c9..b725025 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,3 +27,4 @@ pytz==2024.2 PyYAML==6.0.2 sqlparse==0.5.1 uritemplate==4.1.1 +whitenoise==6.8.2