Configure Whitenoise to serve static files in production
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 21s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 21s
This commit is contained in:
parent
d49fd41bfd
commit
53fe092d65
3 changed files with 7 additions and 0 deletions
|
|
@ -83,6 +83,7 @@ jobs:
|
||||||
|
|
||||||
# ── 6. Run Database Migrations ─────────────────────────────────
|
# ── 6. Run Database Migrations ─────────────────────────────────
|
||||||
./venv/bin/python manage.py migrate --noinput
|
./venv/bin/python manage.py migrate --noinput
|
||||||
|
./venv/bin/python manage.py collectstatic --noinput
|
||||||
|
|
||||||
# ── 7. Configure and restart Systemd service ───────────────────
|
# ── 7. Configure and restart Systemd service ───────────────────
|
||||||
sudo mv /tmp/emailservice.service /etc/systemd/system/emailservice.service
|
sudo mv /tmp/emailservice.service /etc/systemd/system/emailservice.service
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ INSTALLED_APPS = [
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
|
@ -133,6 +134,10 @@ USE_TZ = True
|
||||||
# https://docs.djangoproject.com/en/6.1/howto/static-files/
|
# https://docs.djangoproject.com/en/6.1/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
STATIC_URL = 'static/'
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||||
|
# Simplified static file serving.
|
||||||
|
# https://whitenoise.readthedocs.io/en/latest/django.html#add-compression-and-caching-support
|
||||||
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||||
MEDIA_URL = 'media/'
|
MEDIA_URL = 'media/'
|
||||||
MEDIA_ROOT = BASE_DIR / 'media'
|
MEDIA_ROOT = BASE_DIR / 'media'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,4 @@ six==1.17.0
|
||||||
sqlparse==0.6.0
|
sqlparse==0.6.0
|
||||||
urllib3==2.7.0
|
urllib3==2.7.0
|
||||||
gunicorn==22.0.0
|
gunicorn==22.0.0
|
||||||
|
whitenoise==6.7.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue