Skip to content

Commit 061a337

Browse files
jahandssdnts
authored andcommitted
[Builds] Add additional monorepo info and an examples in advanced-setups.mdx (cloudflare#22191)
1 parent 1b00302 commit 061a337

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/content/docs/workers/ci-cd/builds/advanced-setups.mdx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ sidebar:
88

99
## Monorepos
1010

11+
A monorepo is a single repository that contains multiple applications. This setup can be useful for a few reasons:
12+
13+
- **Simplified dependency management**: Manage dependencies across all your workers and shared packages from a single place using tools like [pnpm workspaces](https://pnpm.io/workspaces) and [syncpack](https://www.npmjs.com/package/syncpack).
14+
- **Code sharing and reuse**: Easily create and share common logic, types, and utilities between workers by creating shared packages.
15+
- **Atomic commits**: Changes affecting multiple workers or shared libraries can be committed together, making the history easier to understand and reducing the risk of inconsistencies.
16+
- **Consistent tooling**: Apply the same build, test, linting, and formatting configurations (e.g., via [Turborepo](https://turborepo.com) in for task orchestration and shared configs in `packages/`) across all projects, ensuring consistent tooling and code quality across Workers.
17+
- **Easier refactoring**: Refactoring code that spans multiple Workers or shared packages is significantly easier within a single repository.
18+
19+
#### Example Workers monorepos:
20+
21+
- [cloudflare/mcp-server-cloudflare](https://github.com/cloudflare/mcp-server-cloudflare)
22+
- [jahands/workers-monorepo-template](https://github.com/jahands/workers-monorepo-template)
23+
- [cloudflare/templates](https://github.com/cloudflare/templates)
24+
- [cloudflare/workers-sdk](https://github.com/cloudflare/workers-sdk)
25+
26+
### Getting Started
27+
1128
To set up a monorepo workflow:
1229

1330
1. Find the Workers associated with your project in the [Workers & Pages Dashboard](https://dash.cloudflare.com).
@@ -41,8 +58,8 @@ ecommerce-monorepo/
4158
│ └── notification-service/
4259
│ ├── src/
4360
│ └── wrangler.toml
44-
├── shared/
45-
│ └── utils/
61+
├── packages/
62+
│ └── schema/
4663
└── README.md
4764
```
4865

@@ -59,6 +76,6 @@ When a new commit is detected in the repository, a new build/deploy will trigger
5976

6077
### Example
6178

62-
Imagine you have a Worker named `my-worker`, and you want to set up two environments `staging` and `production` set in the `wrangler.toml`. If you have not already, you can deploy `my-worker` for each environment using the commands `wrangler deploy --env staging` and `wrangler deploy --env production`.
79+
Imagine you have a Worker named `my-worker`, and you want to set up two environments `staging` and `production` set in the `wrangler.jsonc`. If you have not already, you can deploy `my-worker` for each environment using the commands `wrangler deploy --env staging` and `wrangler deploy --env production`.
6380

6481
In your Cloudflare Dashboard, you should find the two Workers `my-worker-staging` and `my-worker-production`. Then, connect the Git repository for the Worker, `my-worker`, to both of the environment Workers. In the build configurations of each environment Worker, edit the deploy commands to be `npx wrangler deploy --env staging` and `npx wrangler deploy --env production` and the non-production branch deploy commands to be `npx wrangler versions upload --env staging` and `npx wrangler versions upload --env production` respectively.

0 commit comments

Comments
 (0)