Skip to main content
← Back to course

Build Configuration: Nixpacks, Dockerfiles, and Custom Commands

Railway's automatic build detection (Nixpacks, from the Welcome course) handles many projects with zero configuration — but real projects often need more explicit control.

A railway.json (or railway.toml) file gives explicit, version-controlled build/deploy configuration. Rather than relying purely on auto-detection, this file specifies your build command, start command, and other deploy settings directly — committed to your repository, so configuration travels with your code rather than living only in Railway's dashboard.

Bringing your own Dockerfile takes full control when Nixpacks' auto-detection isn't sufficient. If your project has genuinely unusual build requirements, or you already maintain a Dockerfile for other reasons, Railway detects and uses it directly instead of Nixpacks' auto-detection — the same Docker skills from the Visual Studio Mastery track's Build/Publish/Deployment course apply directly here.

Custom build and start commands override defaults for specific needs. Even without a full Dockerfile, you can specify an exact build command and start command in your service settings or railway.json — useful when your project's structure doesn't quite match what Nixpacks assumes.

Watch Paths control which file changes actually trigger a rebuild. For a monorepo (from the Git & GitHub Mastery track's Git at Scale course) with multiple services in one repository, Watch Paths let you configure each Service to only rebuild when files relevant to it actually change — avoiding unnecessary rebuilds of unrelated services on every push.

Build vs. Deploy are genuinely separate phases you can configure independently. A build step (compiling, bundling) and a deploy/start step (actually running your application) can have different commands and different resource needs — understanding this separation helps you configure each correctly rather than treating "deploy" as one undifferentiated step.

Why this matters for you

Auto-detection is a genuinely good default, but real projects eventually need explicit control — knowing railway.json, Dockerfiles, and custom commands exist means you're not stuck if your project's needs outgrow what Nixpacks assumes.

▶️ Before the next lesson

Look at your Railway service's current build settings (Settings → Build) and identify whether it's using Nixpacks auto-detection or a Dockerfile — just to know your current starting point before this course goes deeper.