Fly.io
02 / 02

fly.toml, Deploys & Machines

Fly.io: fly.toml, Deploys & Machines

Fly.io deploys apps as Docker containers run inside Firecracker microVMs ("Machines") across many geographic regions -- Anycast routing sends each user's request to a nearby running instance, so both static and dynamic requests benefit from proximity, not just cacheable content.

Getting Started

# fly launch inspects the project, generates fly.toml (and a
# Dockerfile if the app doesn't already have one)
fly launch

# Deploy -- builds the image, pushes it, rolls out new Machines
fly deploy

# Tail live application logs -- first check after a deploy
fly logs

# SSH directly into a running Machine for debugging
fly ssh console

# Explicit scaling -- set the number of running instances
fly scale count 3
fly scale count 2 --region iad   # per-region control

fly.toml

# fly.toml -- checked into the repo, makes deploys reproducible
app = "my-api"
primary_region = "iad"

[build]
  dockerfile = "Dockerfile"

[env]
  NODE_ENV = "production"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true    # scale to zero when idle
  auto_start_machines = true   # auto-restart on next incoming request
  min_machines_running = 0

  [http_service.concurrency]
    type = "connections"
    hard_limit = 25
    soft_limit = 20             # crossing this can trigger autoscaling

[[http_service.checks]]
  grace_period = "10s"
  interval = "15s"
  method = "GET"
  path = "/healthz"
  timeout = "2s"

Secrets

# Unlike plain [env] values in fly.toml (not secret, checked into git),
# secrets are encrypted and injected only into the running Machine
fly secrets set DATABASE_URL=postgres://... API_KEY=sk_live_...
fly secrets list
fly secrets unset OLD_KEY

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free