Skip to content

Commit

Permalink
Merge pull request #18 from nens/reinout-settings4
Browse files Browse the repository at this point in the history
Settings for staticfiles in production/staging
  • Loading branch information
reinout authored Apr 3, 2024
2 parents bb098ef + c64ffba commit bad03a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ FROM python:3.12
WORKDIR /code
COPY . .
RUN pip install -r requirements.txt
RUN python manage.py collectstatic --force
13 changes: 11 additions & 2 deletions brostar_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
Expand Down Expand Up @@ -120,7 +121,7 @@
}

WSGI_APPLICATION = "brostar_api.wsgi.application"

SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
CORS_ALLOWED_ORIGINS = [
"http://localhost:4200",
]
Expand Down Expand Up @@ -171,8 +172,16 @@

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/

# In production, they're
# hosted via "whitenoise": https://whitenoise.readthedocs.io/en/latest/django.html
STATIC_URL = "static/"
STATIC_ROOT = "/staticfiles"
STORAGES = {
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}


# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ python-dotenv
django-encrypted-model-fields
django-filter
nens-auth-client
whitenoise

# development tools
ruff
Expand Down

0 comments on commit bad03a6

Please sign in to comment.