Fly.io Deployment¶
Deploy RhamaaCMS to Fly.io with a single command.
Why Fly.io?¶
- Fast setup — Deploy in minutes
- PostgreSQL included — Managed database
- Global CDN — Static files served globally
- Django optimized — Built-in support
- Free tier — Start without cost
Prerequisites¶
# macOS
brew install flyctl
# Linux
curl -L https://fly.io/install.sh | sh
# Windows
# Download from https://fly.io/docs/hands-on/install-flyctl/
Step-by-Step Deployment¶
1. Login¶
2. Launch Your App¶
From your project directory:
This will: - Detect Django project - Create fly.toml config - Set up PostgreSQL - Create app on Fly.io
3. Configure Secrets¶
# Generate a secret key
python -c "import secrets; print(secrets.token_urlsafe(50))"
# Set on Fly.io
flyctl secrets set SECRET_KEY=your-generated-key
flyctl secrets set DEBUG=False
4. Deploy¶
Your app is now live at https://your-app.fly.dev!
fly.toml Configuration¶
# fly.toml
app = "your-app-name"
primary_region = "sin" # Singapore
[build]
builder = "heroku/buildpacks:20"
[env]
PORT = "8000"
[http_service]
internal_port = 8000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[statics]]
guest_path = "/app/static"
url_prefix = "/static/"
[[mounts]]
source = "media_data"
destination = "/app/media"
Database¶
Fly.io automatically creates a PostgreSQL database:
# Connect to database
flyctl postgres connect -a your-app-db
# Run migrations
flyctl ssh console -C "python manage.py migrate"
# Create superuser
flyctl ssh console -C "python manage.py createsuperuser"
Database URL¶
Already set as DATABASE_URL environment variable.
Static & Media Files¶
Static Files (WhiteNoise)¶
Already configured in settings/production.py:
Run during deploy:
Media Files (Persistent Volume)¶
For user uploads:
Mount configured in fly.toml above.
Custom Domain¶
# Add your domain
flyctl certs create yourdomain.com
# Configure DNS
# Add CNAME: yourdomain.com → your-app.fly.dev
Update ALLOWED_HOSTS:
Scaling¶
# Scale to 2 machines
flyctl scale count 2
# Change VM size
flyctl scale vm shared-cpu-2x
# Add memory
flyctl scale memory 1024
Useful Commands¶
# View logs
flyctl logs
# Open app in browser
flyctl open
# SSH into machine
flyctl ssh console
# Run management commands
flyctl ssh console -C "python manage.py shell"
# Restart app
flyctl restart
Troubleshooting¶
Build Failures¶
Database Connection Issues¶
# Check database status
flyctl postgres status
# Attach database if detached
flyctl postgres attach your-app-db