Deploying a Monorepo
What is a Monorepo?
A monorepo (short for "monolithic repository") is a software development strategy where multiple projects, services, or packages are stored in a single version-controlled repository. Unlike a polyrepo setup, where each project has its own repository, a monorepo allows teams to manage shared code, enforce consistent tooling, and improve collaboration.
Key Features of a Monorepo:
- Code Sharing: Components within the repository can easily share dependencies and libraries.
- Consistency: Ensures uniform coding standards, tools, and configurations across projects.
- Single Source of Truth: All services and applications exist in a single repository, making version control and dependency management easier.
- Better Collaboration: Teams can work on different services while benefiting from shared knowledge and resources.
- Simplified CI/CD Pipelines: Builds and deployments can be optimized with a unified process across projects.
CloudStation and Monorepos
CloudStation makes it easy to deploy monorepos. The primary type supported is:
- Shared Monorepo – A repository where multiple components share code or configurations from the root directory (e.g., Yarn workspaces or Lerna projects).
Deploying a Shared Monorepo
Shared monorepos are popular in the JavaScript ecosystem and contain multiple components that rely on a common root directory.
By default, all components are built using a single command from the root directory (e.g., npm run build
). However, if you're using Nixpacks, you can override the build command in the service settings.
├── package.json
└── packages
├── backend
│ └── index.js
├── common
│ └── index.js
└── frontend
└── index.jsx
To deploy this type of monorepo in CloudStation, set up a custom start command in the Service Settings for each project that needs to run separately.
Steps to Deploy
- Open the project canvas and select the service you want to configure.
- Navigate to the Settings tab.
- Define a custom start command, such as
npm run start:backend
for the backend andnpm run start:frontend
for the frontend.
Edit this file on GitHub