openCBT

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

  1. Database. Add Railway's PostgreSQL to the project. It is version 18, the version of the image's pg_dump.

  2. 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/opencbt instead needs Railway's Pro plan, because the image is private: there you give Railway a read:packages token under Settings → Source → Registry Credentials.

  3. Variables on the app service:

    VariableValue
    DEPLOYMENT_TARGETcloud for a school's companion, full-cloud for a school entirely online
    OPENCBT_WORKERinline
    DATABASE_URLthe database's private URL, ending ?schema=public&connection_limit=20
    SYNC_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
  4. Volume. Attach one to the app service, mounted at /data.

  5. 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 /data as usual.
  • Updates. Built from the repository, every push to main redeploys. 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.

On this page