Why Fly.io?
- One command deployment:
fly launchhandles everything - Global CDN: Deploy close to your users automatically
- Free tier: Generous free allowance for small forums
- Managed PostgreSQL: Automatic backups and scaling
- Automatic SSL: HTTPS enabled by default
Prerequisites
Install the Fly CLI
Quick deployment
Deploy oForum to Fly.io in three commands:Launch your app
From your oForum source directory:This will:
- Detect the Dockerfile automatically
- Create a new app with a unique name
- Generate a
fly.tomlconfiguration file - Prompt you to create a PostgreSQL database
Set the database URL
If you created a Fly PostgreSQL database, get the connection string:Then set it as a secret:
Fly automatically attaches the database and sets
DATABASE_URL if you created the database during fly launch.Understanding fly.toml
oForum includes afly.toml configuration file:
~/workspace/source/fly.toml
primary_region: Closest region to your users (change toiad,lhr,syd, etc.)internal_port: Must match thePORTenvironment variable (default: 8080)force_https: Redirects all HTTP traffic to HTTPSauto_stop_machines: Stops machines when idle (free tier friendly)memory: 1GB is comfortable for most forums
Database setup
Fly offers managed PostgreSQL with automatic backups:Create a new database
- Name:
oforum-db(or your preference) - Region: Same as your app for lowest latency
- VM size:
shared-cpu-1xwith 256MB for small forums
Attach database to your app
DATABASE_URL secret.
Using an external database
You can also use any PostgreSQL provider (AWS RDS, DigitalOcean, etc.):Secrets management
Never hardcode sensitive data infly.toml. Use secrets instead:
Set secrets
List secrets (values are hidden)
Remove secrets
Environment variables
For non-sensitive configuration, use the[env] section in fly.toml:
fly.toml
fly secrets set.
See the environment variables reference for all available options.
Deployment and updates
Deploy changes
After modifying your code:- Build a new Docker image
- Run database migrations automatically
- Deploy with zero downtime
- Roll back automatically if health checks fail
View logs
Check app status
SSH into your machine
Scale your app
Increase memory:Custom domains
Add your own domain instead ofyour-app.fly.dev:
Certificate validation can take up to 24 hours depending on DNS propagation.
Monitoring and maintenance
View resource usage
- CPU and memory usage
- Request metrics
- Machine status
- Billing information
Database backups
Fly PostgreSQL includes automatic daily backups. To create a manual backup:Health checks
Fly performs automatic health checks on your application. If health checks fail, Fly will:- Stop routing traffic to the unhealthy instance
- Attempt to restart the machine
- Alert you if the problem persists
Pricing and free tier
Fly.io’s free tier includes:- Up to 3 shared-cpu-1x VMs with 256MB RAM
- 3GB persistent storage
- 160GB outbound data transfer
Troubleshooting
Deployment fails
Check the build logs:Database connection errors
Verify the database is attached:DATABASE_URL secret is set: