Monorepo Deployment

Monorepos are a common architectural pattern where multiple projects or components are stored within a single Git repository. Scalingo supports monorepos by allowing you to specify which subdirectory should be deployed for a given application.

The PROJECT_DIR Environment Variable

By default, Scalingo’s deployment system looks for the application’s entry point (e.g. package.json, Gemfile, requirements.txt) at the root of the Git repository.

In a monorepo setup, you need to tell Scalingo which directory contains the application you want to deploy. You can do this by setting the PROJECT_DIR environment variable.

How it Works

When PROJECT_DIR is set:

  1. The build system changes its working directory to the specified folder.
  2. Technology detection (buildpack selection) is performed within that directory.
  3. Only the content of this directory is included in the final application image.

Example Setup

Imagine a repository with the following structure:

.
├── backend/
│   ├── package.json
│   └── src/
├── frontend/
│   ├── package.json
│   └── src/
└── README.md

To deploy the backend and frontend as separate Scalingo applications from this single repository:

  1. Create two applications on Scalingo (e.g., my-app-backend and my-app-frontend).
  2. Connect both applications to the same Git repository.
  3. Configure the environment for each application:
    • For my-app-backend: Set PROJECT_DIR=backend
    • For my-app-frontend: Set PROJECT_DIR=frontend

The next time you push to the repository, each application will build and deploy only its respective subdirectory.

Common Use Cases

  • Backend/Frontend Separation: Keeping your API and client-side code in the same repo but deploying them to different environments.
  • Microservices: Managing multiple microservices in a single repository.
  • Documentation: Keeping your documentation site alongside your application code.

Suggest edits

Monorepo Deployment

©2025 Scalingo