Deploy on Fly.io
How to run OpenSequence on Fly.io with one fly.toml: api and worker process groups from one image, migrations as the release command, secrets set once.
This guide runs OpenSequence as one Fly app with two process groups, api and worker, built from apps/server/Dockerfile. Migrations run as the release command, before any machine is replaced.
fly.toml
Put this at the root of your fork. The Dockerfile copies the whole workspace, so the build context must be the root.
app = "acme-opensequence"
primary_region = "iad"
kill_signal = "SIGTERM"
kill_timeout = 40
[build]
dockerfile = "apps/server/Dockerfile"
# Or skip the build and run the published image (pin a sha- or version tag):
# image = "ghcr.io/lguerberg/open-sequence:main"
[deploy]
release_command = "node /app/dist/cli.js migrate"
strategy = "rolling"
[env]
SEQ_PUBLIC_URL = "https://acme-opensequence.fly.dev"
SEQ_PORT = "8080"
SEQ_LOG_LEVEL = "info"
# One image, two process groups. `env` sets the role, then runs node in its place.
[processes]
api = "env SEQ_ROLES=api node /app/dist/main.js"
worker = "env SEQ_ROLES=worker node /app/dist/main.js"
[http_service]
processes = ["api"]
internal_port = 8080
force_https = true
auto_stop_machines = "off"
auto_start_machines = true
min_machines_running = 1
[[http_service.checks]]
method = "GET"
path = "/readyz"
interval = "15s"
timeout = "3s"
grace_period = "20s"
# The worker has no public service; this check still watches it.
[checks]
[checks.worker_ready]
processes = ["worker"]
type = "http"
port = 8080
method = "GET"
path = "/readyz"
interval = "30s"
timeout = "3s"
grace_period = "30s"
[[vm]]
processes = ["api", "worker"]
size = "shared-cpu-1x"
memory = "512mb"| Line | Why |
|---|---|
kill_signal, kill_timeout = 40 | the worker finishes in-flight messages for up to 30 seconds after SIGTERM, and the process exits within 35 |
release_command | applies the seq and seq_auth migrations once per deploy. If it fails, the deploy stops and no machine changes |
[processes] | the server reads its role from SEQ_ROLES; Fly has no per-process [env], so the command sets it |
http_service.processes = ["api"] | only the api gets a public address. The worker answers the API routes on its port too, so it must not have one |
auto_stop_machines = "off" | an api stopped by Fly would miss provider webhooks and unsubscribe clicks |
/readyz checks | on the api, the database answers; on the worker, the scheduler also ran a job in the last 2 minutes |
Steps
Create the app and a database
fly apps create acme-opensequenceCreate a Fly Managed Postgres cluster, version 14 or newer, in the same region, or use any Postgres the app can reach. Copy its connection string.
Set the secrets
KEY=$(docker run --rm ghcr.io/lguerberg/open-sequence:main node dist/cli.js secrets new-key) # or any built image
fly secrets set --stage \
SEQ_DB_DSN='postgres://oseq:…@…:5432/opensequence' \
SEQ_ENCRYPTION_KEYS="$KEY" \
SEQ_ADMIN_TOKEN="$(openssl rand -base64 32)"Secrets reach every process group and the release command. The worker ignores SEQ_ADMIN_TOKEN. --stage stores them without deploying.
SEQ_ENCRYPTION_KEYS outside Fly. Fly will not show a secret's value again, and a database restored without it has unreadable credentials.Deploy and scale
fly deploy
fly scale count api=2 worker=1Fly builds the image, runs the release command, then rolls the machines.
Create the first project
curl -X POST https://acme-opensequence.fly.dev/v1/admin/projects \
-H "Authorization: Bearer $SEQ_ADMIN_TOKEN" -H "Content-Type: application/json" \
-d '{"slug":"acme","name":"Acme CRM"}'The response holds the first admin key, shown once. Continue with Install, from "Register the providers".
Custom domain
fly certs add sequences.example.com
# then in fly.toml: SEQ_PUBLIC_URL = "https://sequences.example.com"
fly deploySet SEQ_PUBLIC_URL before you save the Allo key: it builds the Allo webhook address and every unsubscribe link.
Check it
fly status # machines per process group and their checks
fly logs # Pino JSON from both groups
curl https://acme-opensequence.fly.dev/v1/admin/engine/health -H "Authorization: Bearer $SEQ_ADMIN_TOKEN"Notes
- No cron. The scheduler runs inside the worker; replicas coordinate through lease rows in Postgres.
- Webhook receivers must be public HTTPS. A
.internalhostname or a private Fly address is refused as a webhook endpoint. - More workers are safe:
fly scale count worker=2. See Scaling.
Qovery
How to run OpenSequence on Qovery from the published image: a managed Postgres, a migration job, and api and worker applications on the same tag.
Kubernetes
How to deploy OpenSequence on Kubernetes: a Secret and ConfigMap, a migration Job, an api Deployment with probes, Service, Ingress and PDB, and a worker.