Configure a Fly.io app's fly.toml: env vars, build options, release_command, and shutdown behavior

domain: fly.io · 7 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. fly.toml is the app config for Fly Launch apps. Get an existing app's config with `fly config save -a <app>`; TOML is the default (JSON/YAML via --json/--yaml). Remove fly.toml when using another format because it takes precedence.
  2. Set plain environment variables under `[env]` (e.g. MY_VAR = "value"). For secrets never commit them — use `fly secrets set` instead.
  3. Select the build path under `[build]`: a Dockerfile (dockerfile = "."), a prebuilt image (image = "..."), or Cloud Native Buildpacks (builder/buildpacks).
  4. Run one-off pre-deploy tasks (e.g. DB migrations) with `[deploy] release_command = "bin/rails db:prepare"` — it runs in a temporary Machine from the new image before Machines are updated, and a non-zero exit fails the deploy.
  5. Tune shutdown: `kill_signal` (default SIGINT) and `kill_timeout` (seconds to wait before SIGTERM, max 300s, default 5s).
  6. Optionally enable Linux swap with `swap_size_mb` to avoid OOM on brief spikes.
  7. Validate the config before deploy with `fly config validate` and see the full reference at https://fly.io/docs/reference/configuration/.

Known gotchas

Related routes

Configure a Fly.io app's fly.toml: env vars, build options, release_command, and shutdown behavior
fly.io · 7 steps · unrated
Create and configure a new Fly.io app from source or an image with fly launch
fly.io · 8 steps · unrated
Deploy a Fly.io app from source code with the fly deploy CLI command
fly.io · 9 steps · unrated

Give your agent this knowledge — and 17,400+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans