Flask Application Deployment¶
Used for kedevo.com, topcoasters.co.uk, and similar apps on VPS3.
Stack¶
| Component | Technology |
|---|---|
| Runtime | Python 3 + Flask |
| WSGI | Gunicorn (2 workers) |
| Process Manager | systemd |
| Reverse Proxy | nginx |
| SSL | Let's Encrypt (certbot) |
Deployment Steps¶
- Create app directory:
/home/deploy/{app_name}/ - Create venv:
python3 -m venv venv - Install deps:
./venv/bin/pip install flask gunicorn - Create
app.pywith Flask application - Create systemd service
- Enable and start:
sudo systemctl enable --now {app} - Create nginx config in
/etc/nginx/sites-available/ - Symlink to sites-enabled, test, reload nginx
- Certbot for SSL:
sudo certbot certonly --webroot -w /var/www/html -d domain.com - Update nginx to include SSL, reload