This skill should be used when the user asks to "deploy to Railway", "configure Railway deployment", "set up Railway for the backend", "add railway.toml", or "configure Railway for a monorepo service".
Configure Railway to deploy the backend from the monorepo using the Dockerfile.
serviceName (required): Railway service name (e.g., news-agregator-backend)rootDir (optional): monorepo subdirectory Railway should treat as the service root — set to apps/backend for the backend servicestartCmd (required): process start command (e.g., node dist/main.js or prisma migrate deploy && node dist/main.js)envVars (required): array of environment variable names that must be set (e.g., ['DATABASE_URL', 'PORT', 'NODE_ENV'])Creates (optional — Railway also accepts manual UI config):
apps/backend/railway.toml — Config-as-Code for Railwayapps/backend/Dockerfile exists (INF-04)Create a Railway project and add a new service named <serviceName> connected to the GitHub repository
In service Settings → Source: set Root Directory to the rootDir input value (e.g., apps/backend). Railway will detect the Dockerfile in that directory automatically.
In service Settings → Variables: add each variable from the envVars input:
envVars, create the variable and set its valueDATABASE_URL: copy from the Railway Postgres service reference (auto-populated when linked)PORT: Railway injects this automatically; set explicitly to 3000 for local clarityNODE_ENV: productionOptionally create apps/backend/railway.toml to pin config as code. Substitute startCmd into startCommand:
[build]
builder = "DOCKERFILE"
dockerfilePath = "Dockerfile"
[deploy]
startCommand = "prisma migrate deploy && node dist/main.js" # replace with startCmd input
healthcheckPath = "/health"
restartPolicyType = "ON_FAILURE"
Note:
dockerfilePathinrailway.tomlis relative torootDir. IfrootDirisapps/backend, theDockerfileatapps/backend/Dockerfileis referenced simply as"Dockerfile".
E_START_CMD_INVALID: Railway does not expand $VAR in start commands with Dockerfile builder → use sh -c 'prisma migrate deploy && node dist/main.js' as the start command, or use the railway.toml startCommand field which accepts shell syntaxE_ENV_MISSING: Build or runtime fails with a missing env var → check the Railway Variables panel; verify every name in the envVars input has a value setSee docs/project-overview.md → "INF-07 — Railway deploy" for the full deploy flow.