This guide deploys the image from revali_docker to Fly.io. It assumes
revali_docker is installed and your app uses AppConfig.fromEnv() so it listens on
0.0.0.0 (see Listen on all interfaces).
1. Install flyctl and log in#
brew install flyctl # macOS
curl -L https://fly.io/install.sh | sh # Linux / macOS
flyctl auth login
On Windows: iwr https://fly.io/install.ps1 -useb | iex. See Fly's install docs.
2. Generate the Dockerfile#
dart run revali build
3. Create the app#
flyctl launch --no-deploy
Answer the prompts, then edit the generated fly.toml so it points at the Revali Dockerfile and health probe:
app = 'my-revali-app'
primary_region = 'lax'
[build]
dockerfile = '.revali/build/Dockerfile'
[env]
PORT = '8080'
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
[[http_service.checks]]
method = 'GET'
path = '/healthz'
interval = '30s'
timeout = '5s'
grace_period = '10s'
-
internal_portmust match the port the server listens on. WithAppConfig.fromEnv()that isPORT. -
/healthzis served by every Revali app, outside the/apiprefix. See Health Probes. -
dockerfilepaths are relative tofly.toml, and the build context is the project root, which is what the generated Dockerfile expects.
4. Set secrets and deploy#
flyctl secrets set DATABASE_URL=postgres://... API_KEY=...
flyctl deploy
Secrets reach the server as environment variables at runtime. Read them with Env.
Values passed to revali build with --dart-define become Docker build arguments instead. Pass them to Fly with
flyctl deploy --build-arg NAME=value.
Deploy from GitHub Actions#
name: Deploy to Fly.io
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart run revali build
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: $
Create the token with flyctl tokens create deploy and store it as the FLY_API_TOKEN
repository secret.
For scaling, regions, volumes and custom domains, see the Fly.io docs.