Build and Start Commands

Railway uses Nixpacks to build and deploy your code with zero configuration. Build and Start commands are automatically detected when an image is built and deployed to a service in Railway.

If necessary, build and start commands can be manually configured.

How it Works

Overrides are exposed in the service configuration to enable customizing the Build and Start commands. When an override is configured, Railway uses the commands specified to build and start the service.

Build Command

The command to build the service, for example yarn run build. Override the detected build command by setting a value in your service settings.

Screenshot of Railway Build Command

Start Command

Railway automatically configures the start command based on the code being deployed.

If your service deploys with a Dockerfile or from an image, the start command defaults to the ENTRYPOINT and / or CMD defined in the Dockerfile.

Override the detected start command by setting a value in your service settings.

Screenshot of custom start command configuration

If you need to use environment variables in the start command for services deployed from a Dockerfile or image you will need to wrap your command in a shell -

/bin/sh -c "exec python main.py --port $PORT"

This is because commands ran in exec form do not support variable expansion.

Support

For more information on how to configure builds, check out the Builds guide section.

For more information on how to configure a service's deployment lifecycle, like the Start command, check out the Deployments guide section.


Edit this file on GitHub