Deploy to Fly.io
Fly.io runs the Docker image directly. You deploy the container from a scaffolded
project (npm create flaghoist@latest team-flags -- --platform container) or a copy of
examples/docker, and back it with Postgres. About ten minutes.
1. Install flyctl and sign in
Section titled “1. Install flyctl and sign in”Install flyctl, then:
fly auth login2. Launch the app
Section titled “2. Launch the app”From the container project (it has the Dockerfile), scaffolded with the CLI or copied from
examples/docker:
fly launch --no-deployAnswer the prompts for a name and region. fly launch detects the Dockerfile and writes a
fly.toml. Make sure its [http_service] block has internal_port = 8080, the port the container
listens on.
3. Attach Postgres
Section titled “3. Attach Postgres”fly postgres create # creates a Postgres appfly postgres attach <pg-app-name> # sets DATABASE_URL on your appFly’s internal Postgres is reached over the private network without TLS, so append ?sslmode=disable
to the connection string it set, otherwise the container tries to negotiate SSL and the connection
fails:
fly secrets set DATABASE_URL="postgres://…internal:5432/<db>?sslmode=disable"Any managed Postgres works too (Supabase, Neon), using its own URL. Those require TLS, which the
container enables by default, so no sslmode is needed.
4. Set the rest of the config
Section titled “4. Set the rest of the config”fly secrets set FLAGS_STORAGE=postgres \ ADMIN_TOKEN="$(openssl rand -hex 32)" \ READ_API_KEY="$(openssl rand -hex 32)"5. Deploy
Section titled “5. Deploy”fly deployFly gives you https://<app>.fly.dev.
6. Verify
Section titled “6. Verify”curl https://<app>.fly.dev/healthCreate a flag from the dashboard at https://<app>.fly.dev/admin (paste your ADMIN_TOKEN), then
read it back:
curl -X POST https://<app>.fly.dev/ofrep/v1/evaluate/flags/new-checkout \ -H "x-api-key: $READ_API_KEY" -H "content-type: application/json" \ -d '{"context":{"targetingKey":"tester-1"}}'Everything Docker-specific is in Deploy with Docker; Fly just runs that image.