New:New releases:CLIcreate-clubedge-app v0.49.1·Clubedge Starter v0.32.0

Clubedge Starter Docs

Fly.io

Deploy the production image to Fly.io with fly.toml, with migrations as the release command.

fly.toml deploys the production image to Fly.io.

A project with a frontend and its API can't use this option yet: it deploys on any container host or Railway. Nor can a project without a website, whose API deploys on any container host or Railway: the CLI refuses this option for it.

pnpm clubedge deploy does these steps for you, databases included.

What fly.toml sets

  • Build: the root Dockerfile. With Next.js, set NEXT_PUBLIC_APP_URL under [build.args], since Next.js compiles it into the build.
  • Release command: node /app/migrate.mjs runs in a temporary machine with the new image, before it replaces the running one. A failed migration stops the deploy.
  • HTTP service: port 3000 with HTTPS forced, machines that stop when idle and start on the next request, and a check on /api/health every 30 seconds.
  • VM: 512 MB of memory.
  • Client address: CLIENT_IP_HEADER = "fly-client-ip" under [env], since Fly's proxy puts each client's address in Fly-Client-IP (Starter v0.27.0 or newer).

Deploy by hand

Install Fly's CLI and sign in with fly auth login, then:

fly launch --no-deploy        # creates the app; keep the existing fly.toml
fly secrets set DATABASE_URL="postgresql://..."
fly deploy

fly launch adds the app's name and region to fly.toml; commit it. Set the other production variables with fly secrets set. For a database on Fly, create Postgres and attach it with fly postgres attach, which sets DATABASE_URL; with cache redis, fly redis create gives you Upstash Redis.

Background jobs

Fly runs the app as a long-lived server, so the jobs worker runs with it. Machines that stop when idle stop the worker too: set min_machines_running = 1 in fly.toml when jobs must run on time.

The deploy workflow

The Deploy job runs flyctl deploy --remote-only: Fly's builders build the image, and the release command runs the migrations before the switch. It needs the secret FLY_API_TOKEN, from fly tokens create deploy.

How is this guide?