Prerequisites
- A Fly.io account
- The Fly CLI (
flyctl) installed - A Turso account
- A Stripe account with live API keys
flyctl:
Create the Fly App
1
Launch the app
Run When prompted:
fly launch from your project root. This creates a fly.toml configuration file.- Choose an app name (e.g.,
bunship-api) - Select your primary region (e.g.,
iadfor Ashburn, Virginia) - Decline the Postgres and Redis add-ons (we will configure them separately)
2
Configure fly.toml
Replace the generated
fly.toml with this configuration:3
Set secrets
Store sensitive values as Fly secrets. These are encrypted and injected as environment variables at runtime.
4
Deploy
Dockerfile.api, pushes it to its internal registry, and starts the machine. Watch the deploy output for the health check to pass.Deploy the Worker
BunShip’s background worker (email sending, webhook delivery, billing sync) runs as a separate Fly app.1
Create a worker app
2
Create fly.worker.toml
3
Set the same secrets
4
Deploy the worker
Turso Integration
Turso and Fly.io work well together because both support edge deployments. Turso can replicate your database to the same regions where your Fly machines run.Create Edge Replicas
Multi-Region Fly Setup
To deploy your API in multiple regions:Redis Setup with Upstash
Fly.io integrates with Upstash for managed Redis. Upstash provides a serverless Redis instance with a REST API and per-request pricing.- Fly Upstash addon
- Upstash directly
Custom Domains
API_URL:
Scaling and Regions
Vertical Scaling
Increase machine size for heavier workloads:Horizontal Scaling
Add more machines in the same or different regions:Autoscaling
Thefly.toml configuration above includes auto_stop_machines and auto_start_machines. Machines that receive no traffic stop automatically, and restart when a request arrives. This keeps costs low during off-peak hours while maintaining instant availability.
Set min_machines_running = 1 to keep at least one machine warm for consistent response times.
Health Checks
Thefly.toml includes an HTTP health check:
Continuous Deployment
GitHub Actions
Add a deploy step to your CI pipeline using the official Fly GitHub Action:FLY_API_TOKEN in your GitHub repository secrets.
Monitoring
fly.io/dashboard with CPU, memory, and network metrics per machine.
For application-level monitoring, configure Sentry:

