Monorepo Support

Support for monorepos is still early. Please follow our roadmap item for more details.

A "monorepo" is roughly defined as a single repository that contains multiple runnable components. For example, a web app may have both a frontend and backend component, which could be completely isolated from one another or share a subset of common code between them.

Railway provides a few features to help improve support for deploying monorepos of various types.

Isolated Monorepo
A repository that contains components that are completely isolated to the directory they are contained in (eg. JS frontend and Python backend)

Shared Monorepo
A repository that contains components that share code or configuration from the root directory (eg. Yarn workspace or Lerna project)

Isolated Monorepo

The simplest form of a monorepo is a repository that contains two completely isolated projects, meaning they do not reference any code or configuration outside their respective directories. They may even be written in completely different programming languages.

To deploy this type of monorepo on Railway, define a root directory for the application when setting up a Deployment Trigger for each project that references the monorepo codebase. Setting this means that Railway will only pull down files from that directory when creating new deployments.

Screenshot of root directory configuration

Shared Monorepo

Popular in the JavaScript ecosystem, shared monorepos contain multiple components that all share a common root directory. All components are built with a single command from the root directory ( eg. npm run build) and only differ in the way they are run ( eg. npm run start:backend and npm run start:frontend).

To deploy this type of monorepo in Railway, define a separate custom start command in Deployment Settings for each project that references the monorepo codebase.

Screenshot of custom start command configuration

Edit this file on GitHub