Skip to content

Commit

Permalink
Use Whitenoise in production
Browse files Browse the repository at this point in the history
  • Loading branch information
janbaykara committed Nov 24, 2023
1 parent a9c5840 commit 1d7f9ab
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@
# print("Warning: MJML is not installed")

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.security.SecurityMiddleware",
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
"livereload.middleware.LiveReloadScript",
"app.middleware.update_stripe_customer_subscription",
Expand Down
4 changes: 3 additions & 1 deletion app/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from .base import *

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

DEBUG = False
SECRET_KEY = os.getenv("SECRET_KEY")
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "*").split(",")
Expand All @@ -21,7 +23,7 @@
DEFAULT_FILE_STORAGE = "app.storage.DigitalOceanSpacesStorage"
AWS_S3_ADDRESSING_STYLE = "virtual"
# like `fra1`
AWS_DEFAULT_ACL = 'public-read'
AWS_DEFAULT_ACL = "public-read"
AWS_QUERYSTRING_AUTH = False
AWS_S3_REGION_NAME = os.getenv("AWS_S3_REGION_NAME")
# like `leftbookclub`
Expand Down
127 changes: 121 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ wagtail-cache = "^2.2.0"
orjson = "^3.9.2"
slippers = "^0.6.2"
django-vite = { git = "https://github.com/Niicck/django-vite", rev = "fix-isDynamicEntry" }
whitenoise = { extras = ["brotli"], version = "*" }

[tool.poetry.dev-dependencies]
bandit = "^1.7.0"
Expand Down

0 comments on commit 1d7f9ab

Please sign in to comment.