Deployment¶
This page covers deploying a generated Django project to production, and how this documentation site itself is published.
Before you deploy¶
- Copy and fill in your environment — every deploy target needs the same core variables:
| Variable | Production value |
|---|---|
SECRET_KEY |
A fresh long random string — never commit it |
DEBUG |
False |
ALLOWED_HOSTS |
yourdomain.com,www.yourdomain.com |
DB_NAME / DB_USER / DB_PASSWORD / DB_HOST / DB_PORT |
Your managed database |
CELERY_BROKER_URL / CELERY_RESULT_BACKEND |
Redis instances (if Celery enabled) |
SENTRY_DSN |
Sentry project DSN (if Sentry enabled) |
| Stripe / storage / email variables | As described in Configuration |
- Run migrations and collect static files:
Deploying with Docker¶
The generated Dockerfile and docker-compose.yml are production-capable.
Development startup is fully automatic (see Integrations):
docker compose up waits for dependencies, applies migrations, and collects
static files before the server starts. Production differs — the image's
default command is gunicorn and it does not auto-migrate. Apply
migrations once as an explicit release step before rolling out new containers:
# Build and run (development)
docker compose up -d --build
# One-shot migration against the release database
docker compose run --rm web python manage.py migrate
docker compose run --rm web python manage.py collectstatic --noinput
# First time only
docker compose exec web python manage.py createsuperuser
docker compose runone-offs go throughentrypoint.sh, which re-applies migrations and static setup (idempotent) before the command. Usedocker compose execagainst a running stack to skip that.
Then put a reverse proxy (nginx, Caddy, Traefik, or your platform's TLS terminator) in
front of web and terminate TLS for your domain.
Cloud provider quick references¶
If you selected a cloud provider at generation time, the project README includes provider-specific instructions. Summary:
- Connect the repository in the Render dashboard.
- Add a Web Service using the Dockerfile (or the Python runtime).
- Set the environment variables from
.[env.example](.env.example). - Deploys automatically on push to your branch.
- Create a new project and link the repository.
- Provision a PostgreSQL plugin (and Redis if Celery is enabled).
- Add the environment variables.
- Deploys automatically on push.
heroku create my_projectheroku addons:create heroku-postgresql:hobby-devheroku config:set DEBUG=False SECRET_KEY=...git push heroku main && heroku run python manage.py migrate
fly auth loginfly launchinside the project (uses the Dockerfile)fly secrets set SECRET_KEY=... DEBUG=Falsefly deploy
Containerize with the provided Dockerfile and push to ECR/GAR/ACR, or use each platform's PaaS. Set the database, Redis, storage, and app environment variables in the platform's secrets manager.
- Push the repo to GitHub and clone it inside a virtualenv on PythonAnywhere.
pip install -r requirements/development.txt- Configure a manual WSGI file pointing at
my_project.wsgi.application. - Run
migrateandcollectstaticfrom a Bash console, then reload the app.
Production settings overrides¶
settings/production.py is the right place to tighten things:
SESSION_COOKIE_SECURE, CSRF_COOKIE_SECURE, SECURE_SSL_REDIRECT,
SECURE_HSTS_SECONDS, and so on. The generated file already points you in the right
direction.
Publishing this documentation site¶
The docs you're reading run on GitHub Pages at https://mds.rianbarriga.com, built with MkDocs Material.
How it works¶
The GitHub Actions workflow
(.github/workflows/docs.yml) runs on every push to main:
- Installs uv + Python and the
docsdependency group - Builds the site with
uv run mkdocs build --strict - Uploads the
site/directory as a Pages artifact - Deploys it with
actions/deploy-pages
The repository's Pages configuration must use "GitHub Actions" as the source (Settings → Pages → Source → GitHub Actions).
The custom domain is declared in the docs/CNAME file, which MkDocs copies verbatim
into the site root.
Pointing the DNS at GitHub¶
To serve mds.rianbarriga.com from this Pages site, configure a CNAME record:
CNAME vs apex
Since the target is a subdomain, a single CNAME (or ALIAS) record is all you need.
For an apex domain you would instead add GitHub's Pages IP A records
(185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153).
After DNS propagates, GitHub issues a TLS certificate for mds.rianbarriga.com
automatically.
Adding or editing pages¶
- Sources live in
docs/. - The sidebar and page order are defined in
mkdocs.yml. - Build locally before pushing: