# Monorepo deployment patterns: one repo, five services

- Date: 2026-07-31T11:03:07.100Z
- URL: https://render.com/articles/monorepo-deployment-patterns-one-repo-five-services

## From five repos to one: the deployment challenge

Your team just finished consolidating a frontend, two APIs, a background worker, and a scheduled reporting job into a single repository. The code migration went fine. Now comes the part nobody planned for: five deployment configurations that used to live in five separate repos must coexist in one, without stepping on each other.

This article covers the five concepts that make monorepo deployment on Render work: *root directories* (anchoring each service to its subdirectory), *build filters* (skipping rebuilds for unaffected services), *shared packages* (handling code multiple services depend on), *environment variable groups* (sharing config without duplication), and *private networking* (letting internal services communicate without public exposure). Everything culminates in a single [Blueprint](https://render.com/docs/infrastructure-as-code) that declares the whole architecture as one version-controlled file.

If your team is newer to the platform, the overview of [how to deploy full stack applications without DevOps expertise](https://render.com/articles/how-to-deploy-full-stack-applications-without-devops-expertise) is useful background on service types before covering monorepo-specific config. And if you want the origin story of these capabilities, see Render's post on [shipping monorepo support](https://render.com/blog/monorepos).

One scoping note: the monorepo-vs-polyrepo debate is out of scope here. You've already decided. This article is about deploying well now that you're here.

## Mapping the repo structure to services

From Render's perspective, a monorepo containing multiple deployable services is still just one Git repository. Render doesn't automatically know that `apps/frontend` and `apps/worker` are separate things, so you create one Render service per deployable unit. Each service points at the same repo but is configured to look at a different part of it.

Here's the example structure used throughout this article:

```text
.
├── apps/
│   ├── frontend/        # Static frontend
│   ├── api-users/       # Public-facing API
│   ├── api-billing/     # Internal-only API
│   ├── worker/          # Background worker
│   └── cron-report/     # Scheduled reporting job
├── packages/
│   └── shared/          # Code shared by multiple services
├── package.json         # Root workspace manifest
└── pnpm-lock.yaml       # Single lockfile for the whole workspace
```

Workspace tools like [Turborepo](https://turbo.build/), [Nx](https://nx.dev/), or [pnpm workspaces](https://pnpm.io/workspaces) are the common reason teams place shared packages under `packages/`. Their specifics aren't covered here. What matters is the structural pattern: independently deployable services under `apps/`, shared code under `packages/`, and a single lockfile and workspace manifest at the repo root. If you want to group these services for shared visibility and management, Render's [Projects](https://render.com/blog/projects) give you a place to organize them.

*Takeaway:* one repo with five services means five Render services with distinct configuration, all pointing at the same repository.

## Root directory: anchoring each service

The root directory setting tells Render where a given service's code lives within the repository. When you set it, Render runs that service's build and start commands *from that directory*, as if it were the top of its own repo. You'll find full details in Render's [monorepo support documentation](https://render.com/docs/monorepo-support).

In a single-service repo, the default (the repo root) is correct. In a monorepo, the right value depends on what the build needs, because files outside a service's root directory are not available to the service at build time or runtime. For a service with no dependencies outside its own directory, that means anchoring the root directory to its subdirectory. But workspace tools force the root directory to a common ancestor of everything the build touches — the root workspace manifest, the lockfile, and any shared packages — which in practice means leaving it at the repo root and scoping the build command to the service instead. See the caveat on shared packages below.

One nuance to keep in mind: you specify the root directory value relative to the repo root. It's an anchor, not a build instruction. It establishes *where* commands execute, but you always write the path from the repository's top level.

A simplified service definition showing this pattern for a service that depends on shared workspace code:

```yaml pseudocode
services:
  - type: web
    name: api-users
    runtime: node
    # rootDir left at the repo root: the install needs the root package.json,
    # pnpm-lock.yaml, and packages/shared, all outside apps/api-users
    buildCommand: pnpm install && pnpm --filter api-users build
    startCommand: node apps/api-users/dist/server.js
    # ... environment variables, health checks, and plan omitted for brevity
```

Note what the scoped build command buys you: the install runs from the repo root, where the workspace manifest, lockfile, and shared packages are all reachable, while `pnpm --filter api-users build` builds only this service. A service with no dependencies outside its own directory can instead set its root directory to that subdirectory and use unscoped commands like `pnpm install && pnpm build`.

*Takeaway:* the root directory anchors where a service's commands run. Set it deliberately for every monorepo service.

## Build filters: skipping unaffected services

By default, Render automatically deploys your service whenever you push any changes to its linked Git branch. If you set a root directory for a service, Render only triggers an autodeploy when your changes affect files under that directory. Build filters give you finer-grained control on top of this. For broader context on how Render's build system evolved to support patterns like this, see the post on [making builds more flexible and performant](https://render.com/blog/build-pipelines).

[Build filters](https://render.com/docs/monorepo-support#build-filters) let you attach a set of paths to a service, and Render only triggers a build for that service when a pushed commit modifies a matching path. Build filters are about efficiency, not correctness. They control *when* a build starts, not *what* gets built or deployed. A misconfigured filter never deploys the wrong code, but it can deploy stale code by skipping builds that should have run.

Here's the most common point of confusion: you write filter paths relative to the repo root, not the service's root directory. Even though `api-users` has its root directory set to `apps/api-users`, its filter must say `apps/api-users/**`, not `**` or `src/**`. Root directory and build filter are independent settings that both happen to be expressed from the repo root.

```yaml pseudocode
services:
  - type: web
    name: api-users
    runtime: node
    rootDir: apps/api-users
    buildFilter:
      # Paths are relative to the repo root, not this service's root directory
      paths:
        - apps/api-users/**
        - packages/shared/**   # Rebuilds this service when shared code changes
        - package.json         # Root manifest changes can affect every workspace build
        - pnpm-lock.yaml       # Dependency updates should trigger rebuilds too
        - render.yaml
```

The pattern generalizes: include the service's own directory, any shared package directories it depends on, and repo-level files (root manifest, lockfile, workspace configuration, and the Blueprint itself) whose changes can alter build output. Omitting those repo-level files is a subtle failure mode. A dependency bump in the lockfile silently skips rebuilding services that consume it.

*Takeaway:* build filters gate build *triggers*, you always write their paths relative to the repo root, and they should cover dependency files, not just source directories.

## Shared packages across services

The `packages/shared` directory introduces a dependency relationship that spans services. Suppose `api-users`, `api-billing`, and `worker` all import validation logic from `packages/shared`. Two things must be true.

First, the shared code must be accessible at build time. Render clones the full repository regardless of a service's configured root directory. However, files *outside* a service's root directory are not available to the service at build time or runtime per Render's monorepo documentation. So shared code that must be imported at build time needs to be reachable through your workspace tooling and dependency resolution, not merely present in the clone. Confirm your workspace setup makes `packages/shared` resolvable from each dependent service's build.

Second, and this is where teams get burned, a change to `packages/shared` must trigger rebuilds of every dependent service, not just one. This connects back to build filters: you need each of the three dependent services to include `packages/shared/**` in its own filter. There's no central declaration of "these services depend on this package." You express the dependency through repetition, once per dependent service's filter.

The failure mode of forgetting this is nasty precisely because it's silent. You fix a bug in shared code, `api-users` rebuilds and picks it up, but `worker` (whose filter never mentioned `packages/shared`) keeps running the old logic until something else triggers its build.

*Takeaway:* add shared package paths to the build filter of *every* service that depends on them.

## Env var groups: shared config without duplication

Five services from one repo tend to share configuration: a database connection string, an external API key, a common log level. Copy-pasting these values across five service definitions works until the day you rotate a credential and update four of the five.

[Environment variable groups](https://render.com/docs/configure-environment-variables#environment-variable-groups) solve this. Define a named set of variables once and reference it from any number of services. Update the group, and every referencing service sees the change. For the full picture on secret storage and rotation, see [how Render handles secrets and environment variables](https://render.com/articles/how-render-handles-secrets-and-environment-variables). Render also provides [new controls for shared service config](https://render.com/blog/new-controls-for-shared-service-config) that are worth reviewing when you manage settings across many services.

A reasonable heuristic: a variable belongs in a shared group when its value is identical across services *and* changes for reasons unrelated to any single service (a shared `DATABASE_URL`, a third-party API key). It belongs per-service when it describes that service specifically, like a port, a feature flag, or a cache TTL. The trade-off with one giant group is blast radius. Every variable becomes visible to every service, and changes ripple everywhere, whether relevant or not.

```yaml pseudocode
envVarGroups:
  - name: shared-config          # Shared across services that need this value
    envVars:
      - key: DATABASE_URL
        sync: false              # Set the real value in the dashboard, never in version control

services:
  - type: web
    name: api-users
    runtime: node
    envVars:
      - fromGroup: shared-config
      - key: USERS_CACHE_TTL     # Defined here because it's specific to this service
        value: "300"
  - type: pserv
    name: api-billing
    runtime: node
    envVars:
      - fromGroup: shared-config
```

*Takeaway:* env var groups eliminate duplicated config. Scope them by "shared by nature," not "shared by convenience."

## Private networking between services

In our example, `api-billing` is internal-only. `api-users` and `worker` call it, but browsers never do. Giving it a public URL just so sibling services can reach it would create unnecessary exposure.

Render services on the same private network can reach each other over internal hostnames without traffic touching the public internet. For a fuller treatment of the underlying concepts, see [how Render handles private networking](https://render.com/articles/how-render-handles-private-networking). Per Render's [private network documentation](https://render.com/docs/private-network), services are on the same private network if they're deployed in the same region *and* they belong to the same workspace. Render also offers a dedicated *private service* type (`pserv` in a Blueprint) with *no* public endpoint at all, which is the right model for `api-billing`.

Private networking isn't a monorepo feature. Any Render services in the same region and workspace share it. But a monorepo makes these internal dependencies visible in one place. You can see in a single file that the worker calls the billing API, which makes them worth designing deliberately rather than defaulting everything to `type: web`. Blueprints can wire internal hostnames into environment variables using `fromService` references, so callers never hardcode addresses.

Private networking is scoped to a single region. Don't assume cross-region internal connectivity without confirming it in the documentation.

*Takeaway:* model internal-only services as private services, and let the platform resolve internal hostnames rather than exposing endpoints publicly.

## The complete blueprint: five services, one file

A [Blueprint](https://render.com/docs/blueprint-spec) is a `render.yaml` file at your repo root that declares services, env var groups, and their relationships as code. By default, Render looks for `render.yaml` at the root of your repo, though you can customize this location during setup. For a five-service monorepo, this is where everything above converges into one reviewable, version-controlled artifact.

A simplified blueprint demonstrating all five services together. You'll want to adapt paths, commands, and plans to your own repo structure:

```yaml pseudocode
envVarGroups:
  - name: shared-config
    envVars:
      - key: DATABASE_URL
        sync: false   # Real value set in the dashboard, not committed

services:
  # Web service serving the frontend
  - type: web
    name: frontend
    runtime: node
    # Every service in this repo depends on packages/shared, so each one leaves
    # rootDir at the repo root — the common ancestor of the root manifest, the
    # lockfile, and packages/shared — and scopes its build with pnpm --filter
    buildCommand: pnpm install && pnpm --filter frontend build
    startCommand: pnpm --filter frontend start
    buildFilter:
      paths:
        - apps/frontend/**
        - packages/shared/**
        - pnpm-lock.yaml
    # ... region, plan, health checks omitted

  # Two APIs, each with their own build filter
  - type: web       # Public-facing API
    name: api-users
    runtime: node
    buildCommand: pnpm install && pnpm --filter api-users build
    startCommand: node apps/api-users/dist/server.js
    buildFilter:
      paths:
        - apps/api-users/**
        - packages/shared/**
        - pnpm-lock.yaml
    envVars:
      - fromGroup: shared-config   # References the shared group defined above
  - type: pserv     # Private service — internal-only, no public endpoint
    name: api-billing
    runtime: node
    buildCommand: pnpm install && pnpm --filter api-billing build
    startCommand: node apps/api-billing/dist/server.js
    buildFilter:
      paths:
        - apps/api-billing/**
        - packages/shared/**
        - pnpm-lock.yaml
    envVars:
      - fromGroup: shared-config

  # Background worker consuming from a shared queue or DB
  - type: worker
    name: worker
    runtime: node
    buildCommand: pnpm install && pnpm --filter worker build
    startCommand: node apps/worker/dist/worker.js
    buildFilter:
      paths:
        - apps/worker/**
        - packages/shared/**
        - pnpm-lock.yaml
    envVars:
      - fromGroup: shared-config
      - key: BILLING_API_HOST      # Internal hostname resolved over the private network
        fromService:
          name: api-billing
          type: pserv
          property: host

  # Scheduled task, runs independently of the always-on services
  - type: cron
    name: cron-report
    runtime: node
    schedule: "0 6 * * *"
    buildCommand: pnpm install && pnpm --filter cron-report build
    startCommand: node apps/cron-report/dist/report.js
    buildFilter:
      paths:
        - apps/cron-report/**
        - packages/shared/**
        - pnpm-lock.yaml
    # ... additional config omitted
```

Walk through it section by section. The `envVarGroups` block defines shared config once, with `sync: false` keeping the secret out of version control (its real value must be set in the dashboard). Every service in this repo depends on `packages/shared`, so each one leaves `rootDir` at the repo root (the common ancestor of the root manifest, the lockfile, and the shared package) and scopes its build to a single service with `pnpm --filter`, pointing its start command at that service's output path under `apps/`. Every `buildFilter` uses repo-root-relative paths and includes `packages/shared/**` where the service depends on it, plus the lockfile so dependency updates trigger rebuilds. Both `api-users` and `api-billing` reference `shared-config` via `fromGroup`. The billing API is `type: pserv`, a [private service](https://render.com/docs/private-services) with no public endpoint, and the worker discovers it through a `fromService` reference that injects the internal hostname at deploy time. The [worker](https://render.com/docs/background-workers) and [cron job](https://render.com/docs/cronjobs) round out the non-web service types. Note that a cron job's `schedule` uses standard cron expression syntax (for example, `0 6 * * *` runs once daily at 06:00 UTC).

*Takeaway:* one file, five heterogeneous services, and every earlier concept visible in a code review diff.

## Common mistakes and how to spot them

- *Filter paths written relative to the service root.* This is the most common error. If a service with `rootDir: apps/api-users` has a filter path of `src/**`, it will never match. Symptom: pushes to the service's own code don't trigger builds.
- *Shared package paths missing from dependent filters.* Symptom: you ship a fix to `packages/shared`, one service picks it up, and others run stale code until their next unrelated deploy.
- *Repo-level dependency files excluded from filters.* Changes to the root `package.json`, lockfile, workspace configuration, or `render.yaml` itself can change build output for every service. If your filters ignore them, dependency bumps silently skip rebuilds.
- *One giant env var group for everything.* Convenient at first, but every service sees every variable, and one change ripples across all five services. Split shared-by-nature config from per-service config.
- *Assuming private networking without checking scope.* Internal hostnames only resolve between services in the same region and workspace. If a `fromService` reference resolves but connections fail, verify both services are deployed in the same region.

## Patterns that scale past five

Nothing here is specific to five services. Root directories anchor services, build filters gate rebuilds, shared package paths propagate into every dependent filter, env var groups centralize shared config, and private services keep internal APIs internal, whether you have three services or thirty. The Blueprint grows linearly. Each new service is one more block following the same decisions you've now seen made five times.

Start by sketching your own repo's directory tree, mark which directories are deployable and which are shared, then draft filters and env var scopes before touching YAML. If you'd rather manage and deploy these services from your terminal, see the walkthrough of [Render's new CLI and refreshed dashboard](https://render.com/blog/introducing-renders-new-cli-and-refreshed-dashboard). From there, the [Blueprint specification](https://render.com/docs/blueprint-spec) is your reference for filling in the details.

## Frequently asked questions

###### Do I need a separate render.yaml for each service in a monorepo?

No. A single `render.yaml` Blueprint at the repo root can declare all of your services, each with its own `rootDir`, `buildFilter`, and environment variables. One file describing five heterogeneous services is easier to review and keep in sync than five separate files.

###### Why isn't my service rebuilding when I push changes to its own directory?

The most common cause is a build filter path written relative to the service's `rootDir` instead of the repo root. For example, a service with `rootDir: apps/api-users` needs a filter path of `apps/api-users/**`, not `src/**` or `**`. Since root directory and build filter paths are independent settings that are both expressed relative to the repo root, double-check that every filter path starts from the top of the repository.

###### Why did a shared package change not get picked up by all the services that depend on it?

Build filters aren't inherited or centrally declared. Each dependent service must individually list the shared package's path (for example, `packages/shared/**`) in its own filter. If one service's filter omits that path, it won't rebuild when the shared code changes, and it will keep running stale logic until an unrelated deploy happens. Audit the `buildFilter.paths` of every service that imports from `packages/shared` to confirm the path is present in each one.

###### Should I put every environment variable in one shared env var group?

No. Use a shared [environment variable group](https://render.com/docs/configure-environment-variables#environment-variable-groups) only for values that are identical across services and change for reasons unrelated to any single service, like a `DATABASE_URL` or a third-party API key. Per-service values like ports, feature flags, or cache TTLs belong on the individual service instead. Putting everything in one group increases blast radius, because every service sees every variable and unrelated changes ripple across all of them.

###### Do all my monorepo services need to be public web services?

No. Internal-only services, like an internal billing API called only by other services, should be declared as `type: pserv` (a [private service](https://render.com/docs/private-services)) with no public endpoint. Private networking works between any Render services in the same region and workspace, per Render's [private network documentation](https://render.com/docs/private-network), and Blueprints can inject internal hostnames into environment variables using `fromService` so callers never hardcode addresses.

###### Why can't my worker resolve the internal hostname of another service in the same Blueprint?

Private networking is scoped to services deployed in the same region *and* the same workspace. If either differs, the internal hostname won't resolve as expected even though a `fromService` reference appears valid in the Blueprint. Check the region setting on both services first, since that's the most common mismatch. This scoping applies to any Render services, not just monorepo-defined ones, so it's worth confirming explicitly rather than assuming.

###### Is shared code under packages/shared automatically available to every service at build time?

Render clones the entire repository regardless of a service's `rootDir`, but files outside a service's root directory aren't usable at build or runtime unless your workspace tooling (like pnpm workspaces, Turborepo, or Nx) makes them resolvable as a dependency. Simply having `packages/shared` present in the clone isn't sufficient. You need working workspace resolution from each dependent service's build step. Confirm this resolves correctly for every service that imports shared code, not just the first one you test.

