Config as Code → IaC migration: railway.toml (NIXPACKS) vs actual Dockerfile build, and safe cutover order
dilson123-tech
HOBBYOP

10 days ago

Hi Railway team,

We're preparing to migrate a production service from Config as Code (railway.toml) to the new Infrastructure as Code (.railway/railway.ts) ahead of the 2026-12-01 deadline. Before touching production, we'd like official guidance on a few points where our observations, the docs and the CLI disagree. So far nothing has been applied: we have only run railway config migrate (local files only) and railway config plan.

Environment

  • One project, production environment, one service (referred to here as my-service), single replica in a single region
  • Source: GitHub repo, auto-deploy from main
  • CLI: railway 5.71.0; IaC SDK: npm [email protected] (Node 22+)

The discrepancy

The repository root contains a railway.toml:

[build]
builder = "NIXPACKS"
buildCommand = "pip install -r backend/requirements.txt -c backend/constraints-prod.txt || pip install -r requirements.txt -c backend/constraints-prod.txt"

[deploy]
startCommand = "bash backend/start.sh"

But the build actually runs from the root Dockerfile:

  • The build log shows load build definition from Dockerfile and runs the Dockerfile's steps.
  • The effective serviceManifest of the current deployment shows builder: DOCKERFILE.
  • The deployment's meta.configFile is "/railway.toml", but the service instance's railwayConfigFile is null.
  • railway config migrate status reports "No services in production read Config as Code".
  • The service instance shows builder: RAILPACK via the API, while railway config plan treats the builder as null.

railway config migrate generated a railway.ts that copies NIXPACKS + buildCommand from the toml. We edited it to match what really runs in production:

  • builder: "DOCKERFILE", dockerfilePath: "/Dockerfile", start: "bash backend/start.sh"
  • healthcheck path with a 600s timeout
  • same region, replica count, domain and port
  • variables unmanaged
  • partial = "my-service"

railway config plan reports "0 to add, 2 to change, 0 to destroy". Both updates are marked safe: build.builder/dockerfilePath (null → DOCKERFILE, /Dockerfile) and deploy.startCommand (null → bash backend/start.sh).

Questions

  1. Precedence of railway.toml vs IaC. The Config File path is null, yet deployments record configFile: "/railway.toml", so the root toml seems to be auto-detected. After railway config apply writes builder/startCommand to the service, does an existing root railway.toml still take precedence over the IaC-managed values? Docs say "configuration defined in code will always override values from the dashboard". Does that still hold for IaC-written values? Also, why does the toml's builder = "NIXPACKS" not take effect today while the Dockerfile wins? Is that expected behavior we can rely on?

  2. Does railway config apply trigger a redeploy? If it does, which configuration would that deployment use while the root railway.toml still exists?

  3. Is railway config migrate cutover required when the Config File path is already null? The CLI says: "Cutover clears each service's Config File path and redeploys it." In our case there is nothing to clear. Would cutover still redeploy, with which configuration, and is it needed for IaC to "own" the service? Since there are no saved paths, what would railway config migrate undo restore?

  4. Safe order for a zero-downtime migration. Our proposed sequence is below. Is it correct, or would you recommend a different order?

    1. Skip cutover, because the path is already null.
    2. railway config plan --out plan.json, then review it.
    3. railway config apply --plan plan.json.
    4. Verify the service instance: DOCKERFILE, /Dockerfile, startCommand.
    5. Remove railway.toml from the repo via PR and merge it, which triggers a normal deploy from main.
    6. Verify the new deployment: no configFile, Dockerfile build, healthcheck passing.

    Is there any step here that could deploy the service with no builder or start command, or with NIXPACKS?

  5. Docs vs CLI 5.71.0. The IaC docs say migrate --apply "clears the Railway Config File settings" and describe manual steps: remove railway.toml, clear the custom path, then plan/apply. They don't mention cutover or undo. The CLI 5.71.0 help says migrate --apply "only touches the filesystem", and Config as Code keeps applying "until you run railway config migrate cutover". After migrate, it suggested the order cutover → plan → apply. Which is authoritative for CLI 5.71.0? Is the plan's null vs the API's RAILPACK for the builder expected?

This is a business-critical production service, so we want to avoid any unplanned redeploy or build-system change. Thanks for your help!

$10 Bounty

2 Replies

Status changed to Awaiting Railway Response Railway • 10 days ago


Railway
BOT

10 days ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • 10 days ago


bpkroll
HOBBY

7 days ago

Thanks for the detailed investigation. I'm preparing a similar migration on Railway Hobby and have the same blank Config File path issue, but with a root-level railway.json.

Our production service runs a single Python worker with a persistent /data volume. The effective restart policy from railway.json is ON_FAILURE with 3 retries, while the dashboard displays 10 retries.

We are using CLI 5.71.0 and preparing .railway/railway.ts, but have not applied any configuration or performed a cutover.

Could Railway staff confirm three things?

  1. Default-file handoff: When the service instance's railwayConfigFile is null but deployments automatically read the root railway.json, is migrate cutover unnecessary? What supported procedure ensures that the existing file stops overriding IaC without an intermediate deployment using dashboard defaults?

  2. Deployment ordering: Is there a supported way to preview and stage the IaC configuration before removing railway.json, without triggering an additional deployment? Does config apply necessarily initiate a deployment for build, start-command or restart-policy changes?

  3. Persistent-volume safety: How can we confirm that the new IaC definition adopts the existing volume and retains its attachment, region, size and data rather than attempting to recreate or replace it? What rollback procedure is supported if the configuration handoff succeeds but the resulting deployment fails?

Our priority is preserving the existing worker, credentials, effective restart policy and database volume through a controlled maintenance migration.

We would appreciate Railway's recommended sequence for CLI 5.71.0 before performing any production-changing operation.


cristid
HOBBY

4 days ago

We have a similar case with 3 services in one project, but our Config File paths are NOT empty and use custom names (/railway.web.json, /railway.api.json, /railway.cron.json), builder NIXPACKS only from those files.

Could Railway staff confirm: (1) config apply while the custom path is still set: safe, and does it redeploy using the file values? (2) migrate cutover seems to target only paths ending in railway.toml/railway.json. For custom-named files, is clearing the path manually in Settings the supported step? (3) After clearing it and deploying, do the values written by IaC take effect?


Welcome!

Sign in to your Railway account to join the conversation.

Loading...