git clone https://github.com/ComeOnOliver/skillshub
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/TerminalSkills/skills/fly-io" ~/.claude/skills/comeonoliver-skillshub-fly-io && rm -rf "$T"
skills/TerminalSkills/skills/fly-io/SKILL.mdFly.io
Overview
Fly.io deploys applications to Firecracker microVMs across 30+ edge regions worldwide, providing sub-50ms latency to users. It supports scale-to-zero machines, persistent NVMe volumes, LiteFS for multi-region SQLite replication, and private WireGuard networking between services.
Instructions
- When deploying applications, use
to auto-detect the framework and generate a Dockerfile, thenfly launch
for zero-downtime rolling updates with health checks.fly deploy - When configuring scaling, use
andauto_stop_machines
inauto_start_machines
to scale to zero when idle and wake on incoming requests, and set machine sizing appropriate to the workload.fly.toml - When managing multi-region deployments, use
to distribute machines,fly scale count --region
header to route writes to the primary region, and LiteFS for SQLite read replicas.fly-replay - When handling persistent data, attach volumes for durable storage (machines are ephemeral), use LiteFS for multi-region SQLite, or Tigris for S3-compatible object storage.
- When connecting services, use
DNS for private service-to-service communication over the WireGuard mesh and never expose internal services to the public internet..internal - When managing secrets, use
for encrypted secret storage accessible as environment variables.fly secrets set KEY=value - When troubleshooting, use
for real-time streaming,fly logs
to access running machines, andfly ssh console
to tunnel to internal services.fly proxy
Examples
Example 1: Deploy a multi-region web application
User request: "Deploy my app globally with Fly.io in US, Europe, and Asia"
Actions:
- Initialize with
and configure Dockerfilefly launch - Deploy machines to three regions:
fly scale count 2 --region iad,cdg,nrt - Set up LiteFS for SQLite replication across regions
- Configure
header for write routing to the primary regionfly-replay
Output: A globally distributed app with read replicas in three regions and automatic write routing.
Example 2: Configure a cost-efficient staging environment
User request: "Set up a Fly.io staging environment that scales to zero when not in use"
Actions:
- Create a staging app with
fly launch - Configure
andauto_stop_machines = "stop"
inauto_start_machines = truefly.toml - Attach a volume for persistent database storage
- Set health checks with appropriate timeouts for routing
Output: A staging environment that stops idle machines and wakes in sub-second on the next request.
Example 3: Canary deployment with auto-rollback
User request: "Deploy my app to Fly.io but test on one machine first. If the health check fails, roll back."
Actions:
- Deploy with
to spin up a single new machine--strategy canary - Health check the canary machine at the app's health endpoint
- If healthy, promote with
to replace all machinesfly deploy --strategy rolling - If unhealthy, rollback with
fly releases rollback
#!/bin/bash # deploy-canary.sh — Fly.io canary deployment with auto-rollback set -euo pipefail APP="${1:?Usage: deploy-canary.sh <app-name>}" HEALTH_PATH="${2:-/api/health}" echo "🐤 Deploying canary..." fly deploy --app "$APP" --strategy canary --wait-timeout 120 HEALTH_URL="https://${APP}.fly.dev${HEALTH_PATH}" HEALTHY=false DEADLINE=$((SECONDS + 60)) while [ $SECONDS -lt $DEADLINE ]; do STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$HEALTH_URL" || true) [ "$STATUS" = "200" ] && HEALTHY=true && break sleep 3 done if [ "$HEALTHY" = true ]; then echo "✅ Canary healthy! Promoting..." fly deploy --app "$APP" --strategy rolling echo "🎉 Production deploy complete" else echo "❌ Canary failed! Rolling back..." fly releases rollback --app "$APP" echo "⏪ Rolled back" exit 1 fi
Guidelines
- Use
for dev/staging to save costs; machines stop after idle timeout.auto_stop_machines = "stop" - Keep
so machines wake on incoming requests with sub-second cold start.auto_start_machines = true - Use
DNS for service-to-service calls; never expose internal services publicly..internal - Store persistent data on volumes, not the machine filesystem, since machines are ephemeral.
- Use LiteFS for SQLite apps needing multi-region reads; it is simpler than PostgreSQL replication.
- Set health checks with realistic timeouts; Fly Proxy uses them for routing, not just monitoring.
- Use
header for write operations in multi-region setups to route to the primary region.fly-replay