| name | fly-deploy |
| description | Deploy containers globally to Fly.io with multi-region support, managed Postgres, volumes, and Firecracker microVMs using the fly CLI. Trigger: when deploying to Fly.io, using flyctl, fly launch, fly deploy, managing Fly machines, Fly Postgres, multi-region deployment |
| version | 1 |
| argument-hint | [launch|deploy|status|logs|ssh|scale|secrets|postgres] |
| allowed-tools | ["bash","read","write","edit","glob","grep"] |
Fly.io Deployment
You are now operating in Fly.io deployment mode using the fly CLI (flyctl).
Prerequisites
brew install flyctl
curl -L https://fly.io/install.sh | sh
fly auth login
export FLY_API_TOKEN="your-token-here"
fly auth whoami
Initializing a New App
fly launch
fly launch --yes
fly launch --no-deploy
fly launch --name my-app --region iad --yes
fly launch --org my-org --yes
Application Configuration (fly.toml)
app = "my-app"
primary_region = "iad"
[build]
dockerfile = "Dockerfile"
[env]
PORT = "8080"
ENVIRONMENT = "production"
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
[[http_service.checks]]
grace_period = "10s"
interval = "30s"
method = "GET"
path = "/health"
timeout = "5s"
[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 256
Deploying
fly deploy
fly deploy --strategy rolling
fly deploy --strategy canary
fly deploy --strategy bluegreen
fly deploy --strategy immediate
fly deploy --wait-timeout 120s
fly deploy --image registry.fly.io/my-app:v1.2.3
fly deploy --regions iad
fly deploy --verbose
Checking Status
fly status
fly status --json
fly machine list
fly machine list --json
fly machine status <machine-id>
fly apps list
Viewing Logs
fly logs
fly logs --json
fly logs --region iad
fly logs --machine <machine-id>
fly logs | grep -i error
fly logs --json | jq 'select(.level == "error")'
Scaling
fly scale count 3
fly scale count 2 --region iad
fly scale count 1 --region lhr
fly scale vm shared-cpu-1x
fly scale vm shared-cpu-2x
fly scale vm shared-cpu-4x
fly scale vm performance-1x
fly scale vm performance-2x
fly scale show
Multi-Region Configuration
fly regions add ord lax ams
fly regions remove lhr
fly regions list
fly regions set-primary iad
fly scale count 2 --region ord
fly scale count 2 --region lax
fly deploy
Secrets Management
fly secrets set DATABASE_URL="postgresql://..."
fly secrets set \
DATABASE_URL="postgresql://..." \
API_KEY="sk_live_..." \
JWT_SECRET="..."
fly secrets list
fly secrets unset DATABASE_URL
fly secrets import < .env.production
SSH Access
fly ssh console
fly ssh console -C "ls /app"
fly ssh console --machine <machine-id>
fly ssh console --region lax
fly ssh sftp get /app/logs/app.log ./app.log
Volumes (Persistent Storage)
fly volumes create myapp_data --region iad --size 10
fly volumes list
fly volumes extend <volume-id> --size 20
fly volumes show <volume-id>
Managed Postgres
fly postgres create --name myapp-db --region iad
fly postgres create --name myapp-db --region iad --initial-cluster-size 1 --vm-size shared-cpu-1x --volume-size 10
fly postgres attach myapp-db --app my-app
fly postgres connect -a myapp-db
fly postgres status -a myapp-db
fly postgres list
fly postgres failover -a myapp-db
fly postgres detach myapp-db --app my-app
Deployment Patterns
Pattern 1: Single-Region Production Deploy
fly deploy
fly status --json | jq '.Machines[] | {id, state, region}'
fly logs 2>&1 | head -50
fly status | grep "Hostname:"
Pattern 2: Multi-Region Deployment
fly launch --yes
fly regions add ord lax ams
fly scale count 2 --region ord
fly scale count 2 --region lax
fly scale count 1 --region ams
fly deploy
fly status --json | jq '.Machines[] | {region, state}'
Pattern 3: App with Managed Postgres
fly postgres create --name myapp-db --region iad
fly launch --name myapp --region iad --no-deploy
fly postgres attach myapp-db --app myapp
fly deploy
fly ssh console -C "psql \$DATABASE_URL -c 'SELECT 1'"
VM Sizing Reference
| VM Size | CPUs | RAM | Price/Month |
|---|
| shared-cpu-1x | 1 shared | 256 MB | ~$1.94 |
| shared-cpu-2x | 2 shared | 512 MB | ~$3.88 |
| shared-cpu-4x | 4 shared | 1 GB | ~$7.76 |
| performance-1x | 1 dedicated | 2 GB | ~$31 |
| performance-2x | 2 dedicated | 4 GB | ~$62 |
Free Tier
- 3 shared-cpu-1x VMs with 256 MB RAM
- 3 GB persistent volume storage
- 160 GB outbound data transfer
- Shared IPv4, dedicated IPv6
Safety Rules
- Never commit
FLY_API_TOKEN to source control — use environment variables or CI secrets.
- Use
fly secrets set for sensitive values; never pass them via environment variables in fly.toml.
- Test locally with Docker before deploying to Fly.io.
- Use
fly deploy --strategy rolling (default) to avoid downtime during updates.
- Always check
fly status after deployment to confirm machines are healthy.
- SSH (
fly ssh console) can be used for emergency debugging — avoid running destructive commands.
- Volumes cannot be moved between regions — plan region placement before creating volumes.
- Postgres
fly postgres failover promotes a replica — only use in emergency, not routine maintenance.