Running on Fly
deploy/fly.toml runs one copy of Lyra on Fly.io, with Postgres on Neon and uploaded files in Tigris, Fly’s S3-compatible storage. There’s no Redis and no server of your own to look after. This is how Lyra cloud runs.
docs.acme.com ──▶ Fly (HTTPS) ──▶ Lyra ──┬──▶ Neon (Postgres) └──▶ Tigris (uploaded files)| Machine | One shared-cpu-1x machine with 512 MB of memory, in Frankfurt (fra) |
| HTTPS | Fly gets the certificate and sends every http request to https |
| Database changes | Run as the release command, before each deploy starts the new version |
| Sleeping | The machine is suspended when nobody has Lyra open, and wakes on the next request |
| Health check | Fly calls /ready every 30 seconds |
Set it up
Section titled “Set it up”-
Create a Postgres database on Neon and copy its connection string.
-
Create the app, its storage and its secrets:
Terminal window fly apps create <app> --org <org>fly storage create -a <app> -n <app>-files # sets the AWS_* secrets Lyra readsfly secrets set -a <app> --stage DATABASE_URL=... AUTH_SECRET=... GOOGLE_CLIENT_ID=... GOOGLE_CLIENT_SECRET=...AUTH_SECRETis at least 32 random characters. Add the secrets for the sign-in methods you want, and for email (SMTP_URLorSES_REGION, andEMAIL_FROM). -
In
deploy/fly.toml, changeapp,APP_URLandS3_BUCKETto yours. Remove or change the other values under[env]that belong to Lyra cloud, such asOLD_APP_HOSTSand the links to its terms and privacy policy. -
Add
https://<app>.fly.dev/api/auth/google/callback, or the same on your own domain, to the Google client’s redirect URIs. -
Deploy from the root of Lyra’s code:
Terminal window fly deploy -c deploy/fly.toml --ha=false --build-arg APP_VERSION=$(git rev-parse --short HEAD) .
Every later update is the same fly deploy command. Settings lists everything else you can set, as secrets or under [env].
What’s different from one server with Docker
Section titled “What’s different from one server with Docker”- Background jobs only run while the machine is awake. Work that falls due while it sleeps waits until the next request wakes it.
- There’s no Redis. Live events and rate limits stay in the one copy’s memory, so it must run as exactly one copy, which
--ha=falsein the deploy command makes sure of. To run more, see More than one machine. - Scripts run as a separate process. A command run with
fly ssh console, such asusers.tsororgs.tsfrom Day to day, can’t tell the server about its changes live without Redis, so people may need to reload to see them. - Smaller database pool.
fly.tomlsetsDATABASE_POOL_SIZEto 5. - Backups come from Neon and Tigris. Use Neon’s restore to an earlier point in time for the database, and back up the bucket for files, instead of the commands in Backups.