Setup and deploy
How to deploy Lingo to Fly.io and configure sign-in and machine translation. To run it on your machine, see Local development.
Local development
To run Lingo on your machine, follow Local development.
Deploying to Fly.io
The production app is <your-app>, Fly org <your-org>, region ams —
https://<your-app>.fly.dev. One Fly app, two process groups built from the
same image: web (Next standalone, 512MB) and worker (the bundled pg-boss
worker, node app/dist/worker.js, 256MB).
The worker runs large imports in the background, delivers webhooks and deletes usage statistics older than 90 days; without it, imports stay queued, webhooks are never sent and old usage statistics are kept. An import that was queued or running while the worker was down is picked up when the worker is back.
Before the first deploy, edit app/fly.toml (or a private copy that you pass to --config): set app to your app name, and replace https://lingo.example.com with your public URL in AUTH_URL, in NEXT_PUBLIC_APP_URL under [env], and in NEXT_PUBLIC_APP_URL under [build.args].
One-time setup (run from the repo root):
# 1. Install flyctl: https://fly.io/docs/hands-on/install-flyctl/
# 2. Authenticate
fly auth login
# 3. Create the web app (don't deploy yet)
fly apps create <your-app> --org <your-org>
# 4. Provision Postgres 15 or newer in the same region. Use at least 512MB —
# a 256MB instance thrashed into an outage under a ~1200-key import.
# Then set up backups: see "Database backups" below.
fly postgres create --name lingo-db --org <your-org> --region ams \
--vm-size shared-cpu-1x --volume-size 1 --initial-cluster-size 1
# 5. Attach the database (this writes DATABASE_URL into the web app's secrets)
fly postgres attach lingo-db --app <your-app>
# 6. Set the required secret before the first deploy
fly secrets set --app <your-app> --stage \
AUTH_SECRET=$(openssl rand -base64 32)
Sign-in providers and DeepL are optional; see the sections below.
app/fly.toml sets AUTH_TRUST_HOST=true, AUTH_URL and NEXT_PUBLIC_APP_URL
in [env]; see Required settings behind a proxy.
NEXT_PUBLIC_APP_URL is set in both [env] and
[build.args], since it's baked into the client bundle at image build time, not
read at runtime. For GitHub and Google sign-in, see Sign-in providers.
Then every deploy, from the repo root:
fly deploy . --config app/fly.toml --build-arg GIT_SHA=$(git rev-parse --short HEAD)
GIT_SHA is optional: it is baked into the image and reported as sha by
/api/health (unknown without it), so you can check which commit is live
with one curl.
The . makes the monorepo root the build context (the Dockerfile expects to see
pnpm-workspace.yaml, app/, packages/, docs/). Multi-stage build first
installs workspace deps, then builds Next.js in standalone mode, then ships a
slim runtime image. Don't add --dockerfile app/Dockerfile — flyctl resolves
that flag (and the config's dockerfile key) relative to the config file's
directory, so it would look for app/app/Dockerfile and fail. fly.toml already
has dockerfile = "Dockerfile" for exactly this reason.
After the first deploy, scale to one machine per process group (Fly defaults to HA pairs):
fly scale count web=1 worker=1 --app <your-app>
Migrations on deploy
Migrations run automatically on every deploy via release_command in
app/fly.toml (node app/dist/migrate.js — the bundled Drizzle migrator, with
migrations copied into the image). No manual migration step is needed against
production.
Reading magic links from logs
Unless you set RESEND_API_KEY, no email is sent, so magic links and
invitation links print to the web machine's stdout. Tail them with:
fly logs --app <your-app>
Health check
To check that a running instance is wired up, open /api/health. It returns { status: "ok" } when the app can reach the database. Fly polls GET /api/health every 30s. The endpoint pings Postgres; it returns 503 if the DB is unreachable, and also 503 with db: "timeout" if the ping takes longer than 2s — what an operator sees during DB distress rather than a full outage.
Database backups
A Postgres app made with fly postgres create has two kinds of backup. Turn on both.
Daily volume snapshots are on by default and kept for 5 days. A snapshot holds the database as it was when it was taken, so restoring one can lose up to a day of changes. Keep them longer:
fly volumes list --app lingo-db # note the volume id
fly volumes update <volume-id> --app lingo-db --snapshot-retention 30
Snapshots taken before the change keep their old retention.
Point-in-time backups upload every database change to a storage bucket at least once a minute and take a full backup every 24 hours, so you can restore the database as it was at any moment in the last 7 days. They need at least 512MB of memory on the database machine.
fly volumes extend <volume-id> --app lingo-db --size 3 # room on disk, see below
fly postgres backup enable --app lingo-db
fly secrets deploy --app lingo-db # restarts the database
fly postgres backup list --app lingo-db
fly postgres backup enablecreates a Tigris bucket and asks you to accept Tigris's terms. It has no flag for that, so run it in an interactive terminal.fly secrets deployrestarts the database to apply the bucket's credentials. Expect a few seconds in which/api/healthreportsdb: "timeout"; the web app and the worker reconnect on their own. The first full backup starts as soon as the database is back.- Changes that have not been uploaded yet wait on the database's disk. If uploads keep failing, they pile up until the disk is full and the database stops, so leave room on the volume and check now and then. In
fly postgres connect --app lingo-db,select archived_count, failed_count, last_failed_time from pg_stat_archiver;should showarchived_countgrowing andfailed_countat 0. fly postgres backup config show --app lingo-dbshows the schedule;fly postgres backup create --app lingo-dbtakes a full backup now.
Restoring never touches the running database: each way creates a new Postgres app next to it.
# From a snapshot (as it was when the snapshot was taken)
fly volumes snapshots list <volume-id>
fly postgres create --name lingo-db-restored --snapshot-id <snapshot-id> \
--image-ref <image of the old app, see fly status --app lingo-db> \
--org <your-org> --region ams --initial-cluster-size 1 \
--vm-size shared-cpu-1x --vm-memory 512 --volume-size <at least the snapshot's VOL SIZE>
# To a moment in time (UTC, within the last 7 days)
fly postgres backup restore lingo-db-restored --app lingo-db \
--restore-target-time 2026-10-21T09:30:00Z
The copy keeps every database user and password, so to switch the app over, change only the host in its DATABASE_URL (from lingo-db.flycast to lingo-db-restored.flycast). Read the current value with fly ssh console --app <your-app> -C 'printenv DATABASE_URL', then fly secrets set --app <your-app> DATABASE_URL='<new value>', which restarts the app. Delete a copy you no longer need with fly apps destroy <name>.
Search engines and link previews
The landing page and the docs are open to search engines. /robots.txt tells crawlers to stay out of /app, /api, /oauth and /invite, and /sitemap.xml lists the landing page and every docs page. Shared links show a preview image, served at /opengraph-image.
The sitemap and the preview image use NEXT_PUBLIC_APP_URL for their addresses, so they point at the wrong host until that is set to your public URL.
Sign-in providers
Lingo offers up to four ways to sign in. Email magic links are on unless you restrict sign-in to GitLab groups. GitHub, GitLab and Google each appear on the sign-in page only when you set their credentials, so a local setup needs no OAuth application.
Email magic links
On by default. Turned off while sign-in is restricted to GitLab groups (see below). Lingo sends a one-time sign-in link that expires after 24 hours. Invitations to join an organisation are sent the same way.
- With
RESEND_API_KEYset, Lingo sends the email through Resend. SetEMAIL_FROMto the sender address. - Without
RESEND_API_KEY, nothing is emailed. The link prints to thewebmachine's output instead (see Reading magic links from logs).
GitHub
Set AUTH_GITHUB_ID and AUTH_GITHUB_SECRET. Both are required; the "Continue with GitHub" button hides otherwise. Create the OAuth application with the callback URL https://<your-lingo-host>/api/auth/callback/github.
GitLab
Set AUTH_GITLAB_ID and AUTH_GITLAB_SECRET. Both are required; the "Continue with GitLab" button hides otherwise. This provider signs people in with gitlab.com accounts. Create an application at https://gitlab.com/-/user_settings/applications with the redirect URI https://<your-lingo-host>/api/auth/callback/gitlab and the scope read_user.
Google (always domain-locked)
Google sign-in is never open. Set all three of these together:
AUTH_GOOGLE_IDandAUTH_GOOGLE_SECRET: the OAuth client credentials.AUTH_GOOGLE_ALLOWED_DOMAINS: comma-separated email domains, for exampleacme.com. If you set the credentials without it, the app refuses to boot.
Only Google accounts whose verified email is on an allowed domain can sign in. The match is exact, so subdomains don't count. This applies whether or not the GitLab group restriction below is on.
To enable it:
-
In Google Cloud Console, go to APIs & Services, then Credentials, and create an OAuth 2.0 Client ID (web application) with the redirect URI
https://<your-lingo-host>/api/auth/callback/google. An Internal consent screen (Workspace only) adds a second, Google-side layer of the same restriction. -
Set the secrets:
fly secrets set --app <your-app> \ AUTH_GOOGLE_ID=... AUTH_GOOGLE_SECRET=... AUTH_GOOGLE_ALLOWED_DOMAINS="acme.com"Set all three together; credentials without domains refuse to boot.
With exactly one allowed domain, Lingo also tells Google to pre-filter its account chooser to that domain. This is cosmetic only; the check on the server is what enforces the restriction.
To remove Google sign-in, unset all three secrets. People who signed up through Google keep their accounts and sessions. They lose only the Google sign-in button.
Restricting sign-in to GitLab groups
Set AUTH_GITLAB_ALLOWED_GROUPS to one or more gitlab.com group full paths, comma-separated, for example acme or acme,acme/translators. When it is set:
- Only members of those groups or their subgroups can sign in.
- Email magic-link sign-in is disabled. GitLab, plus Google if you configured it, are the only ways in.
- Sign-in fails closed. If GitLab can't confirm membership, sign-in is denied.
To roll it out:
-
Make sure the gitlab.com OAuth application permits the
read_apiscope. Lingo needs it to list a person's groups. Existing users re-authorize on their next sign-in. -
Set the secret:
fly secrets set --app <your-app> AUTH_GITLAB_ALLOWED_GROUPS="acme" -
To turn the restriction off, unset the secret. Sign-in returns to open.
Lockout warning: while the restriction is on, email is disabled. A wrong group path locks out everyone who has no working Google sign-in. If Google is configured, accounts on an allowed domain can still get in. Recover by correcting or unsetting the secret.
Required settings behind a proxy
AUTH_SECRETis required in production. Generate one withopenssl rand -base64 32. In local development and tests Lingo falls back to a built-in dev-only secret.- Outside Vercel (Fly.io and similar), also set
AUTH_TRUST_HOST=trueandAUTH_URL=<public origin>, for examplehttps://<your-app>.fly.dev. Behind another platform's proxy the app can't work out its public address. WithoutAUTH_URLit mints magic links that point athttps://0.0.0.0:3000instead of your real URL.
app/fly.toml already sets AUTH_TRUST_HOST=true. Its AUTH_URL is a placeholder; replace it with your public URL.
Machine translation (DeepL)
Machine translation is optional. Set a DeepL API key on the server to turn it on:
DEEPL_API_KEY=... # Free keys end in `:fx` and use api-free.deepl.com automatically
# Optional override; otherwise the endpoint is inferred from the key
DEEPL_API_URL=https://api.deepl.com
Without DEEPL_API_KEY:
- The sparkle button on each value is switched off. Its tooltip reads Machine translation is not set up on this Lingo instance.
- Translate missing with DeepL is still shown, but reports an error when used.
- The "Machine-translate into all languages" checkbox in the New key dialog is hidden.
Continuous deploys from GitHub Actions (optional)
Add a FLY_API_TOKEN repository secret (fly tokens create deploy), then:
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy . --config app/fly.toml --remote-only --build-arg GIT_SHA=${GITHUB_SHA::7}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}