Deploy to Railway
Put the starter on a public HTTPS address with the Railway template, connect your repository, add your own domain and switch on the extras.
Updated · 3 min read
The README's Deploy on Railway button creates the whole production setup with no input: Postgres, the API and a public web service, on one private network. The first deploy takes 10 to 20 minutes. Then you make yourself an admin, connect your own repository and add a domain.
Deploy the template
-
Open the README on GitHub and click Deploy on Railway. Sign in to Railway if asked.
-
The template creates three services:
Postgres,server(the API, which runs migrations before each deploy) andweb(the app behind a Caddy proxy, the only public service). It also generates the auth secret. -
Wait for
serverandwebto show Active. The first build is the slowest. -
Open the
webservice's public domain (Settings → Networking) and add/health/ready. It says{"status":"ready"}. -
Sign up on the live site.
-
Make yourself an admin. In Railway, open the Postgres service's Data tab and run:
UPDATE "user" SET role = 'admin' WHERE email = 'you@example.com';Or, with the Railway CLI and
psqlinstalled, runrailway connect Postgresand paste the same line. -
Reload, open Admin → Pages and click Install site template.
Railway bills by usage. Check their pricing before you deploy.
Deploy your own copy
The button builds the starter's own repository. To deploy your copy, and have every push redeploy, open server and web in Railway in turn, go to Settings → Source and connect your GitHub repository. Keep the root directory and the Dockerfile paths the template set: deploy/server.Dockerfile and deploy/web.Dockerfile, held in each service's RAILWAY_DOCKERFILE_PATH variable.
Keep server and Postgres private. Only web gets a public domain. The app and the API share that one HTTPS address, and sign-in cookies depend on it.
Use your own domain
- Add the domain to
webwith target port8080, or runrailway domain <domain> -s web -p 8080. - Create the CNAME and
_railway-verifyTXT records Railway shows, at your DNS provider. On Cloudflare, set both to DNS only so Railway can issue the certificate. - On
server, setBETTER_AUTH_URLandAPP_ORIGINtohttps://<your domain>and redeployserver. Sign-in is refused from any other address. - Update the Google and GitHub callback URLs if you use them.
Passkeys belong to the host in
APP_ORIGIN. Ones added on the Railway domain stop working on your own domain, so move to your domain before people add passkeys.
Separate api. and mcp. hosts are optional. Add them to web the same way, set API_HOST and MCP_HOST on web and MCP_URL=https://mcp.<domain> on server, then redeploy both. The api. host sends / to the API reference; the mcp. host is the address agents connect to. See Agents and the API.
Switch on the extras
Each one is off until its variables are set on server in Railway, or in apps/server/.env locally. Each takes a redeploy or a restart.
| Turn on | What you set | More |
|---|---|---|
| Payments | STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_PRO, STRIPE_PRICE_TEAM (test mode first) | Plans and billing |
| Account emails | LOOPS_API_KEY and the template ids | |
| Google or GitHub sign-in | GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET, or GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET | Sign-in and accounts |
| Analytics in PostHog | POSTHOG_PROJECT_KEY and POSTHOG_HOST on server, plus VITE_POSTHOG_PROJECT_KEY and VITE_POSTHOG_HOST on web | Analytics and the audience |
| A public demo login | DEMO_EMAIL and DEMO_PASSWORD for an account whose role is viewer | The admin panel |
| Affiliate report access for scripts | AFFILIATES_READ_TOKEN, at least 32 characters | The affiliate program |
The VITE_POSTHOG_* values are compiled into the web app, so change them and rebuild web.
Until Loops is set up, password-reset and verification emails can't be delivered. Set it up before you invite real users.
In production, new passwords are checked against Have I Been Pwned, which needs outbound HTTPS from server. Set PWNED_PASSWORD_CHECK=off to skip it. Admin changes need a passkey sign-in from the last 15 minutes; set ADMIN_PASSKEY_STEP_UP=off only where admins can't use passkeys.
Check the deploy
- The
serverdeploy log showsMigrations up to date, thenAPI started. curl https://<domain>/health/readyreturns{"status":"ready"}.- Sign up, sign out, sign in, and create an organisation at
/organisations. - Without Stripe keys, the billing page says billing is off. With them, subscribe with a test card and check the webhook's delivery log in Stripe shows 200s.
Not using Railway
The same app runs anywhere with Docker Compose and Caddy. Copy deploy/.env.example to deploy/.env and set PUBLIC_HOST, POSTGRES_PASSWORD, DATABASE_URL (same password, URL-encoded) and BETTER_AUTH_SECRET (openssl rand -base64 48). Then:
docker compose --env-file deploy/.env -f deploy/compose.yaml config
docker compose --env-file deploy/.env -f deploy/compose.yaml up --build -d
Point DNS at the host and Caddy obtains the certificate for PUBLIC_HOST.
Something unclear or missing? Ask us and we'll answer, then fix the page.


