Fly io

From TerminalSkills/skills · View interactive version

Fly io is an AI agent skill from the GitHub repository TerminalSkills/skills. Assists with deploying applications globally on Fly.io edge infrastructure. Use when deploying Docker-based apps, configuring multi-region machines, setting up persistent storage, or managing global databases. Trigger words: fly.io, fly deploy, fly machines, fly launch, multi-region, edge deployment

How to use this skill

Skill file

Fly.io

Overview

Fly.io runs applications as Firecracker microVMs (Fly Machines) in the regions you choose (17 at the time of the last check; see fly platform regions), with Fly Proxy routing traffic to the nearest healthy machine. It supports scale-to-zero machines, persistent volumes, Tigris object storage, and private WireGuard networking (6PN) between apps. LiteFS (multi-region SQLite replication) still exists but Fly states it offers no support for it, so treat it as a community tool. The CLI is fly (alias flyctl); checked against flyctl v0.4.120.

Instructions

Examples

Example 1: Deploy a multi-region web application

User request: "Deploy my app globally with Fly.io in US, Europe, and Asia"

Actions:

  1. Initialize with fly launch and configure Dockerfile
  2. Add machines in three regions, one command per region so each gets its own count: fly scale count 2 --region iad, then cdg, then nrt
  3. Use managed Postgres (or LiteFS if you accept it is unsupported) for data
  4. Return a fly-replay: region=iad response header on writes so Fly Proxy re-runs them in the primary region
fly launch --name storefront-web --region iad
fly scale count 2 --region iad
fly scale count 2 --region cdg
fly scale count 2 --region nrt
fly scale show

Output: fly scale show lists machines in iad, cdg and nrt; reads are served locally and writes are replayed to iad.

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:

  1. Create a staging app with fly launch
  2. In fly.toml under [http_service] set auto_stop_machines = "stop", auto_start_machines = true, min_machines_running = 0
  3. Attach a volume for persistent database storage
  4. Set health checks with appropriate timeouts for routing
[http_service]
  internal_port = 8080
  auto_stop_machines = "stop"
  auto_start_machines = true
  min_machines_running = 0

[[mounts]]
  source = "data"
  destination = "/data"

Output: A staging environment that stops idle machines and wakes 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:

  1. Define a health check ([[http_service.checks]] with path = "/api/health", grace_period, interval)
  2. fly deploy --strategy canary boots one new machine, waits for its checks, then rolls the rest automatically; if checks fail the deploy aborts and the old machines keep serving
  3. Fly has no fly releases rollback command. To go back to an earlier build, find its image with fly releases --image and run fly deploy --image registry.fly.io/orders-api:deployment-01JABCDEF
  4. A rollback reuses current fly.toml and secrets and does not undo database migrations
# deploy-canary.sh: canary deploy; on failure, redeploy the last known-good image
set -euo pipefail
APP="${1:?usage: deploy-canary.sh orders-api registry.fly.io/orders-api:deployment-01JABCDEF}"
GOOD_IMAGE="${2:?find it with: fly releases --app $APP --image}"

if fly deploy --app "$APP" --strategy canary --wait-timeout 5m; then
  echo "canary passed its health checks, all machines updated"
else
  echo "deploy failed, redeploying $GOOD_IMAGE"
  fly deploy --app "$APP" --image "$GOOD_IMAGE" --strategy immediate
  exit 1
fi

Guidelines

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.