From flyio-pack
Implements Fly.io advanced deployments: blue-green via Machines API, canary releases, multi-region rollouts using fly CLI and health checks.
npx claudepluginhub jeremylongshore/claude-code-plugins-plus-skills --plugin flyio-packThis skill is limited to using the following tools:
Advanced deployment strategies for Fly.io beyond `fly deploy`. Covers blue-green with the Machines API, canary with traffic splitting, and multi-region coordinated rollouts.
Implements TypeScript clients and patterns for Fly.io Machines API: typed REST calls, lifecycle management, state waiting, multi-region deployments with Docker images.
Deploys and manages Fly.io apps using Docker containers, Fly Machines, fly.toml configs, databases, volumes, secrets. Supports fly launch/deploy, debugging, multi-region setups for Python/Node/Rails/Django apps.
Provides quick reference for Fly.io PaaS deployments including fly.toml config, global distribution, scaling patterns, secrets management, health checks, and troubleshooting. Auto-loads on fly.toml detection.
Share bugs, ideas, or general feedback.
Advanced deployment strategies for Fly.io beyond fly deploy. Covers blue-green with the Machines API, canary with traffic splitting, and multi-region coordinated rollouts.
async function blueGreenDeploy(appName: string, newImage: string) {
const client = new FlyClient(appName, process.env.FLY_API_TOKEN!);
const oldMachines = await client.listMachines();
// 1. Create new machines (green) with updated image
const greenMachines = await Promise.all(
oldMachines.map(m => client.createMachine(
{ ...m.config, image: newImage }, m.region
))
);
// 2. Wait for all green machines to be healthy
await Promise.all(greenMachines.map(m => client.waitForState(m.id, 'started')));
// 3. Verify health
for (const m of greenMachines) {
const healthy = await checkHealth(`https://${appName}.fly.dev/health`);
if (!healthy) {
// Rollback: destroy green, keep blue
await Promise.all(greenMachines.map(m => client.destroyMachine(m.id)));
throw new Error('Health check failed — rolled back');
}
}
// 4. Stop old machines (blue)
await Promise.all(oldMachines.map(m => client.stopMachine(m.id)));
console.log(`Deploy complete: ${greenMachines.length} new machines`);
}
# Deploy new version to a single machine
fly deploy -a my-app --strategy canary
# Monitor for 10 minutes
fly logs -a my-app --no-tail &
sleep 600
# If healthy, complete rollout
fly deploy -a my-app --strategy rolling
# If unhealthy, rollback
fly releases rollback -a my-app
# Deploy region by region
for region in iad lhr nrt; do
echo "Deploying to $region..."
fly deploy -a my-app --region $region
# Health check per region
curl -sf "https://my-app.fly.dev/health" \
-H "Fly-Force-Instance-Id: $(fly machine list -a my-app --json | jq -r ".[] | select(.region==\"$region\") | .id" | head -1)"
echo "Region $region healthy. Continuing..."
done
For webhook and event handling, see flyio-webhooks-events.