A **monorepo** is a single Git repository that contains the source code for multiple related applications:

```bash
# A monorepo containing a Python backend and a JavaScript frontend

📁 my-monorepo
|
├── README.md
├── 📁 backend
│   ├── app.py
│   ├── README.md
│   ├── requirements.txt
│   └── 📁 tests
│       └── test_app.py
└── 📁 frontend
    ├── 📁 components
    │   └── login.js
    ├── index.js
    ├── package.json
    ├── README.md
    └── 📁 src
        └── auth.js
```

You can deploy the individual apps in a monorepo as separate Render services. You can also configure each service to redeploy only if you make changes to its corresponding files:

- **Set a service's [root directory](/content/docs/monorepo-support#setting-a-root-directory/index.html)** to ignore file changes _outside_ that directory.
- **Set [build filters](/content/docs/monorepo-support#setting-build-filters/index.html)** to ignore file changes that match specific [path patterns](/content/docs/monorepo-support#filter-syntax/index.html).

Specify any combination of a root directory and build filters to customize your service's autodeploy behavior.

## Setting a root directory

By default, Render [automatically deploys](/content/docs/deploys#automatic-deploys/index.html) your service whenever you push _any_ changes to its linked Git branch. If you set a **root directory** for your service, Render only triggers an autodeploy if your changes affect files anywhere under that directory. This helps you avoid unnecessary deploys when working in a monorepo.

Files outside your service's root directory are not available to the service at build time or at runtime.

Set your service's root directory in any of the following ways:

1. In the [Render Dashboard](https://dashboard.render.com/), open the **Settings** page for the service you want to configure.
2. Scroll down to the **Build & Deploy** section and find the **Root Directory** setting:

3. Click **Edit**.
4. Specify the root directory to use and click **Save Changes**.
5. In the dialog that appears, verify your service's build and start commands (which will now run relative to the new root directory).
6. Click **Update Fields**.

Set the `rootDir` field in a request to the Render API's [Update Service](https://api-docs.render.com/reference/update-service) endpoint.

In the same request, update values for the following fields as needed to be relative to the new root directory:

- `buildCommand`
- `startCommand`
- `preDeployCommand`
- `dockerfilePath`
- `dockerContext`
- `staticPublishPath`

**Use this method only if you manage your services with [Blueprints](/content/docs/infrastructure-as-code/index.html).**

1. In your Blueprint's `render.yaml` file, add the `rootDir` key to the definition of each applicable service:

```yaml
services:
  - type: web
    name: app-backend
    runtime: python
    rootDir: backend
    buildCommand: pip install -r requirements.txt
    startCommand: python app.py
  - type: web
    name: app-frontend
    runtime: node
    rootDir: frontend
    buildCommand: npm install
    startCommand: npm start
```

2. For each of the following fields that your service uses, update the values as needed to be relative to the new root directory:
   - `buildCommand`
   - `startCommand`
   - `preDeployCommand`
   - `dockerfilePath`
   - `dockerContext`
   - `staticPublishPath`
3. Save and deploy your changes.

If you don't set a root directory, Render uses the repository root as the default.

### Root-relative settings

Render runs commands and interacts with files relative to your service's root directory. All of the following settings operate relative to the root directory:

- Build command
- Start command
- Pre-deploy command
- Publish directory
- Dockerfile path
- Docker build context directory

If you _don't_ set a root directory for a monorepo-backed service, the service's build command might look like this:

```shell
$ cd backend && go build -o app . # Starts at repository root
```

Setting the service's root directory to the `backend` directory simplifies the build command to this:

```shell
$ go build -o app . # Starts in backend directory
```

## Setting build filters

Set **build filters** for your service to specify which files in your repo do (or don't) trigger an autodeploy when you push changes to them:

Configure your service's build filters in any of the following ways:

1. In the [Render Dashboard](https://dashboard.render.com/), open the **Settings** page for the service you want to configure.
2. Scroll down to the **Build & Deploy** section and find the **Build Filters** setting.
3. Click **Edit**.
4. Click **\+ Add Included Path** and/or **\+ Add Ignored Path** as needed.
5. Enter the [path patterns](/content/docs/monorepo-support#filter-syntax/index.html) for all paths you want to include and ignore.
6. Click **Save Changes**.

Set the `buildFilter` field in a request to the Render API's [Update Service](https://api-docs.render.com/reference/update-service) endpoint.

Here's an example payload:

```json
{
  "buildFilter": {
    "paths": ["frontend/**"],
    "ignoredPaths": ["docs/**", "README.md"]
  }
}
```

Note that the property name for included paths is `paths` (not `includedPaths`).

**Use this method only if you manage your services with [Blueprints](/content/docs/infrastructure-as-code/index.html).**

Add the `buildFilter` key to the definition of each applicable service in your Blueprint's `render.yaml` file:

```yaml
services:
  - type: web
    name: app-frontend
    runtime: node
    rootDir: frontend
    buildCommand: npm install
    startCommand: npm start
    buildFilter:
      paths:
        - frontend/**
      ignoredPaths:
        - docs/**
        - README.md
```

### Filter rules

Build filters can define rules for included paths, ignored paths, or both:

| Path type | Description |
| --- | --- |
| **Included paths** | Changes that match an included path **will** trigger an autodeploy, **unless** those files also match an ignored path.<br>- If you specify at least one included path, all non-matching paths are automatically ignored (you don't need to specify them as ignored paths).<br>- If you don't specify any included paths, _all_ file changes trigger an autodeploy unless they match an ignored path. |
| **Ignored paths** | Changes that match an ignored path **will not** trigger an autodeploy, **even if** those files also match an included path.<br>In other words, ignoring a path takes precedence over including it. |

Build filter paths are always relative to your _repository_ root, even if you’ve set a different [root directory](/content/docs/monorepo-support#setting-a-root-directory/index.html). This means your build filters _can_ include paths from other directories in your repo.

### Filter syntax

Build filters use **glob syntax** to define the patterns for included and ignored file paths. See supported wildcards and example usage below:

| Syntax &<br> Description | Example |
| --- | --- |
| **`?`**<br>Matches any single character except the file path separator `/` | `frontend/sample.?s`<br>Matches:<br>- frontend/sample. **t** s<br>Does not match:<br>- frontend/index.js<br>- frontend/components/login.jsx |
| **`*`**<br>Matches zero or more characters except the file path separator `/` | `backend/util/*.go`<br>Matches:<br>- backend/util/ **util**.go<br>- backend/util/ **util_test**.go<br>Does not match:<br>- backend/main.go<br>- backend/util/readme.md |
| **`**`**<br>Matches zero or more directories or sub-directories | `**/readme.md`<br>Matches:<br>- readme.md<br>- **backend**/readme.md<br>- **frontend/src**/readme.md<br>Does not match:<br>- backend/main.go<br>- frontend/index.js |
| **`[abc]`**<br>Matches one character specified in the bracket | `frontend/src/auth[nz].js`<br>Matches:<br>- frontend/auth **n**.js<br>- frontend/auth **z**.js<br>Does not match:<br>- frontend/src/auth.js |
| **`[^abc]`**<br>Matches one character that is NOT specified in the bracket | `backend/build/[^ax]*.sh`<br>Matches:<br>- backend/build/ **q** uemu.sh<br>Does not match:<br>- backend/build/x86.sh<br>- backend/build/amd64.sh |
| **`[lo-hi]`**<br>Matches one character (c) within the range lo <= c <= hi | `backend/**/*[0-9].sh`<br>Matches:<br>- backend/build/x8 **6**.sh<br>- backend/build/amd6 **4**.sh<br>Does not match:<br>- backend/build/quemu.sh |
| **`[^lo-hi]`**<br>Matches one character (c) that is NOT within the range lo <= c <= hi | `backend/build/*[^0-9].sh`<br>Matches:<br>- backend/build/quem **u**.sh<br>Does not match:<br>- backend/build/x86.sh<br>- backend/build/amd64.sh |

## Using with service previews

Your service's root directory and build filters also affect the creation of [pull request previews](/content/docs/service-previews#pull-request-previews-git-backed/index.html) (if you've enabled them). If you open a pull request that only modifies ignored files for a service, Render skips creating a preview instance for that pull request.

A file might be ignored because it's outside your service's [root directory](/content/docs/monorepo-support#setting-a-root-directory/index.html), or because it matches one of your build filter's [ignored paths](/content/docs/monorepo-support#filter-rules/index.html).

## FAQ

###### Can I ignore changes to my repo's Blueprint files?

**No.** Changes to a [Blueprint's](/content/docs/infrastructure-as-code/index.html) YAML file (usually `render.yaml`) are always processed regardless of your build filters. Blueprint syncs are also unaffected by build filters.

###### Do build filters affect any deploys besides autodeploys?

**No.** If you trigger a [manual deploy](/content/docs/deploys#manual-deploys/index.html) or update your service's configuration (such as its build command or start command), Render always proceeds with the deploy regardless of your build filters.

###### Do build filters do anything if I've disabled autodeploys?

**Yes.** Although build filters don't affect your service's deploys in this case, they can still affect the creation of [pull request previews](/content/docs/monorepo-support#using-with-service-previews/index.html).

###### Do build filters and root directory work with preview environments?

**Yes.** If you define the root directory or specify build filters for each service in your Blueprint file, Render only creates a [preview environment](/content/docs/preview-environments/index.html) if the files changed in a pull request match the root directory or build filter paths for at least one service.
