# Twenty on Railway (GitOps)

This folder is the repo-managed (GitOps) definition of our **Twenty CRM** stack on Railway.
For the full operator/runbook, see: `twenty/AGENTS.md`.

## What is managed as code vs in Railway UI

- **In this repo (code):** app containers + service-level Railway config (`twenty/web/*`, `twenty/worker/*`) + GitOps variable intent (`twenty/railway/*`)
- **In Railway UI:** project creation, Postgres/Redis services, custom domains

## Services (one Railway project)

Create these services inside the same Railway project:

1. **Postgres** database service
2. **Redis** database service
3. **twenty-web**
   - Root Directory: `twenty/web`
   - Config-as-code: `/twenty/web/railway.json`
4. **twenty-worker**
   - Root Directory: `twenty/worker`
   - Config-as-code: `/twenty/worker/railway.json`

## Variables

- Canonical variable list + docs: `twenty/.env.example`
- We manage variables using the **Railway CLI** (no repo scripts).
- Prefer Railway reference variables for wiring:
  - `PG_DATABASE_URL=${{Postgres.DATABASE_URL}}`
  - `REDIS_URL=${{Redis.REDIS_URL}}`

To update variables:
1) `cd twenty/web` (or `twenty/worker`)
2) `railway link --project <projectId> --environment production --service "Twenty"` (web) / `"Twenty Worker"` (worker)
3) `railway variables --set "KEY=VALUE" --set "KEY2=VALUE2" --skip-deploys`

## Custom domain (cultscale.org)

1. Add `cultscale.org` on the **twenty-web** service (Railway UI).
2. Update `dns/zones/cultscale.org.yaml` apex `ALIAS` to the provided `*.up.railway.app.` target.
3. Validate: `cd dns && make validate`.
