DDD: whitenoise

Why?

> One is that WhiteNoise is designed to work in situations where Apache, nginx
> and the like aren’t easily available. But more importantly, it’s easy to
> underestimate what’s involved in serving static files correctly

We deal with both these situations:

* for local development, we recommend running with DEBUG=False and still want to
  sever staticfiles

* for deploying using nginx/whatever, I'd like to keep my instructions as simple
  as possible, and doing this right once (in whitenoise) saves us from having to
  come up with the right instructions for a bunch of webservers.
This commit is contained in:
Klaas van Schelven
2024-05-16 10:31:52 +02:00
parent 6c9cc2ab4f
commit 0f0a4f996c
4 changed files with 24 additions and 1 deletions

3
.gitignore vendored
View File

@@ -43,3 +43,6 @@ node_modules
# conf
/bugsink_conf.py
# static files
/collectedstatic

View File

@@ -66,6 +66,7 @@ TAILWIND_APP_NAME = 'theme'
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@@ -174,6 +175,7 @@ STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / "static",
]
STATIC_ROOT = BASE_DIR / "collectedstatic"
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

View File

@@ -107,6 +107,23 @@ bugsink-manage createsuperuser
This will create a new user account with administrative privileges.
## Collect static files
Bugsink uses static files for its web interface.
You can collect the static files by running:
```bash
bugsink-manage collectstatic --noinput
```
You should see something like
```
123 static files copied to '/path/to/your/working/dir/collectedstatic'.
```
## Run the Bugsink server
The recommended way to run Bugsink is using Gunicorn, a WSGI server.
@@ -118,7 +135,7 @@ PYTHONUNBUFFERED=1 gunicorn --bind="127.0.0.1:9000" --access-logfile - --capture
```
You should see output indicating that the server is running. You can now access Bugsink by visiting
http://localhost:9000/ in your web browser.
http://127.0.0.1:9000/ in your web browser.

View File

@@ -8,6 +8,7 @@ pygments==2.16.*
inotify_simple
brotli
python-dateutil
whitenoise
# testing/development only:
requests