Skip to main content

Introduction

The Wagtail Bakery Demo is designed to be deployed on various platforms with flexible infrastructure options. This guide covers the deployment strategies, infrastructure requirements, and platform-specific considerations.

Deployment Options

The project supports multiple deployment strategies:

Docker

Deploy using Docker containers with docker-compose for local or cloud environments

Heroku

One-click deployment to Heroku with automated builds and releases

Infrastructure Requirements

Core Services

The Wagtail Bakery Demo requires the following services to run in production:
1

PostgreSQL Database

Version: PostgreSQL 18.1 or higher recommendedThe application uses PostgreSQL as its primary database. Configure via the DATABASE_URL environment variable.
DATABASE_URL=postgres://user:password@host:5432/database
2

Redis Cache (Optional but Recommended)

Version: Redis 8.4 or higher recommendedRedis is used for caching and session storage to improve performance. Configure via REDIS_URL or REDIS_TLS_URL.
REDIS_URL=redis://redis-host:6379
If Redis is not available, the application will fall back to Django’s local memory cache backend.
3

Python Runtime

Version: Python 3.12The application is built and tested with Python 3.12. Ensure your deployment environment supports this version.
4

WSGI Server

Server: uWSGIThe production build uses uWSGI as the application server with the following configuration:
  • 2 worker processes
  • 4 threads per worker
  • HTTP keep-alive enabled
  • Static file serving at /media/

Optional Services

Purpose: Media file storageFor AWS S3:
AWS_STORAGE_BUCKET_NAME=your-bucket
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_S3_REGION_NAME=us-east-1
AWS_S3_CUSTOM_DOMAIN=cdn.example.com
For Google Cloud Storage:
GS_BUCKET_NAME=your-bucket
GS_PROJECT_ID=your-project-id
Purpose: Frontend cache purgingConfigure Cloudflare for automatic cache purging when content is published:
FRONTEND_CACHE_CLOUDFLARE_ZONEID=your-zone-id
FRONTEND_CACHE_CLOUDFLARE_BEARER_TOKEN=your-token

Environment Configuration

Required Environment Variables

These variables must be set for production deployments:
VariableDescriptionExample
DJANGO_SECRET_KEYDjango secret key for cryptographic signingyour-secret-key-here
DATABASE_URLPostgreSQL connection stringpostgres://user:pass@host/db
DJANGO_SETTINGS_MODULEDjango settings modulebakerydemo.settings.production

Optional Environment Variables

VariableDescriptionDefault
REDIS_URLRedis connection stringNone (falls back to local memory)
DJANGO_ALLOWED_HOSTSComma-separated list of allowed hosts*
PRIMARY_HOSTPrimary domain for admin emailsNone
DJANGO_DEBUGEnable debug mode (should be off in production)off
Never set DJANGO_DEBUG=on in production environments. This exposes sensitive information and creates security vulnerabilities.

Deployment Architecture

Container-Based Deployment

The Docker-based deployment architecture:
┌─────────────────────────────────────────┐
│         Load Balancer / Proxy           │
└───────────────┬─────────────────────────┘

┌───────────────▼─────────────────────────┐
│   App Container (uWSGI + Django)        │
│   - Port 8000                           │
│   - Static files via WhiteNoise         │
│   - Media volume mounted                │
└─────┬──────────────────────┬────────────┘
      │                      │
┌─────▼──────────┐    ┌──────▼────────────┐
│   PostgreSQL   │    │      Redis        │
│   Container    │    │    Container      │
└────────────────┘    └───────────────────┘

Platform-as-a-Service Deployment

For Heroku and similar PaaS platforms:
┌─────────────────────────────────────────┐
│            Heroku Router                │
└───────────────┬─────────────────────────┘

┌───────────────▼─────────────────────────┐
│         Web Dyno (uWSGI)                │
│   - Auto-scaling enabled                │
│   - Static files via WhiteNoise         │
└─────┬──────────────────────┬────────────┘
      │                      │
┌─────▼──────────┐    ┌──────▼────────────┐
│   Heroku       │    │   Heroku Redis    │
│   Postgres     │    │                   │
└────────────────┘    └───────────────────┘

Security Considerations

Important Security SettingsThe production settings include several security features enabled by default:
  • HTTPS redirect (SECURE_SSL_REDIRECT=True)
  • HSTS header (30 days by default)
  • XSS filter enabled
  • Content type nosniff enabled
  • Secure proxy SSL header detection

Basic Authentication

Optionally enable basic authentication for staging environments:
BASIC_AUTH_ENABLED=true
BASIC_AUTH_LOGIN=username
BASIC_AUTH_PASSWORD=password
BASIC_AUTH_WHITELISTED_HTTP_HOSTS=example.com,admin.example.com

Static Files and Media

Static Files

Static files are handled by WhiteNoise with compression and manifest storage:
  • Storage Backend: whitenoise.storage.CompressedManifestStaticFilesStorage
  • Collection: Static files are collected during the Docker build process
  • Serving: Efficiently served by WhiteNoise middleware

Media Files

Media files (user uploads, images) can be stored:
  1. Local Volume (Docker): Mounted at /code/bakerydemo/media/
  2. AWS S3: Configure with AWS_STORAGE_BUCKET_NAME
  3. Google Cloud Storage: Configure with GS_BUCKET_NAME
For production deployments with multiple instances, use cloud storage (S3 or GCS) to ensure media files are accessible across all instances.

Next Steps

Docker Setup

Learn how to deploy with Docker and docker-compose

Heroku Deployment

Deploy to Heroku in minutes

Production Settings

Understand production configuration options

Getting Started

Start with local development first

Build docs developers (and LLMs) love