Skip to content
mango·agentby Mangosteen Studio
Server setup · Railway

Deploy on Railway

Railway builds the Dockerfiles from GitHub, runs the backend and panel as two services, and hosts Postgres with pgvector. Migrations run in a pre-deploy step on every release.

$5–10 / month (Hobby plan) Almost none Needs a key in GOOGLE_CREDENTIALS_JSON

1Project and database#

  • Choose New project → Deploy from GitHub repo with the mango-agent repo. This becomes the backend service.
  • Add a Postgres with pgvector template. The first migration runs CREATE EXTENSION vector, which a plain Postgres doesn't have.
  • Redis: Upstash (rediss://…) or Railway's Redis.

2Backend service#

Set the Railway config file to deploy/railway/backend.json (Dockerfile, pre-deploy uv run alembic upgrade head, /health check). Add the domain api.<domain> on port 8000, then set the variables:

bash
PORT=8000
DATABASE_URL=postgresql+asyncpg://${{Postgres.PGUSER}}:${{Postgres.PGPASSWORD}}@${{Postgres.PGHOST}}:${{Postgres.PGPORT}}/${{Postgres.PGDATABASE}}
GOOGLE_CREDENTIALS_JSON=<base64 of the service-account key>
# + everything under "backend" in deploy/env.production.example

3Panel service#

Add a second service from the same repo with config file deploy/railway/panel.json, and the domain app.<domain> on port 3000. Railway passes the service's variables to the Docker build, so set the NEXT_PUBLIC_* values (API URL, WebSocket URL, Firebase web config) there, plus API_URL_INTERNAL=http://${{backend.RAILWAY_PRIVATE_DOMAIN}}:8000 and PORT=3000.

4First owner and updates#

bash
npm i -g @railway/cli && railway login && railway link
railway ssh --service backend
uv run python -m app.seeds.load seeds/example   # or your own seed folder

Pushing to the connected branch redeploys, and migrations run before the new version takes traffic. If the panel calls localhost, the NEXT_PUBLIC_* values were missing at build time: set them, then redeploy.