Deploying Django application on VPS
Published on 7/12/2025
The django project is scafolded using Cookiecutter.
Following changes are made:
- Create a common compose file, which includes postgres, traefik etc.
- These are common containers for all apps in the VPS
- Named the volumes, created a network, ‘include’ common compose in production compose file
- All services are set to the new network, django instances are to be named uniquely
- Login to postgres shell, psql, and manually create a DB for the project
- VPS setup is stored as a seperate Git repo, for reproducability
- Brevo setup for transactional emails, which also required domain verification
- Sentry also used for application monitoring
- The static files are served with whitenoise, without CDNs
- Media files are served from Cloudflare R2 private repo
- Upload was smooth, but for viewing, signed URLs were required
- The default cookiecutter AWS option, generates some incorrect options for the Cloudflare R2
- Removed AWS cli container from production compose file
- Hetzner VPS is setuped. It is chosen, as it is much cheaper than AWS lightsnail.
- Firewall setup at VPS using ufw. Source cloned from git. Secrets copied over ssh.