On Railway
A cloud companion or a full-cloud school without a server of your own.
Railway builds the image itself from the repository's Dockerfile, so there is
no machine to keep patched. It suits a handful of schools; past that, one VPS
running a stack per school is cheaper and is what the compose files are built
for. Moving later is the same image: restore the database, copy /data across,
point the domain.
One service, not two
On a VPS the app and the worker are separate containers sharing the /data
volume. A Railway volume attaches to one service only, so here they run
together: OPENCBT_WORKER=inline makes the app's container start the worker
beside it. If either stops, the whole service stops and Railway restarts both.
Setting one up
-
Database. Add Railway's PostgreSQL to the project. It is version 18, the version of the image's
pg_dump. -
App. Add a service from the GitHub repository, connecting Railway's GitHub app to it once. Railway finds the Dockerfile at the root and builds from it. Pulling the published image
ghcr.io/reelmza/opencbtinstead needs Railway's Pro plan, because the image is private: there you give Railway aread:packagestoken under Settings → Source → Registry Credentials. -
Variables on the app service:
Variable Value DEPLOYMENT_TARGETcloudfor a school's companion,full-cloudfor a school entirely onlineOPENCBT_WORKERinlineDATABASE_URLthe database's private URL, ending ?schema=public&connection_limit=20SYNC_KEYcloud companion only — the same secret as the school's own server SUPER_ADMIN_USERNAME,SUPER_ADMIN_PASSWORDfull-cloud only RAILWAY_RUN_UID0— the volume is mounted for root, and the app writes to it -
Volume. Attach one to the app service, mounted at
/data. -
Network. Generate a domain, or add the school's own. Set the health check path to
/api/health.
Migrations run each time the service starts, before it takes any request, as on every other deployment.
What is different here
- Backups. The nightly backup service in the compose files does not exist
here; turn on Railway's own database backups. "Back up now" in Settings still
works, and writes to
/dataas usual. - Updates. Built from the repository, every push to
mainredeploys. Once a school depends on it, turn off automatic deploys and deploy a chosen commit by hand — the same rule as pinning a school's server, for the same reason.