Skip to content

Commit b43a351

Browse files
committed
[Builds] Add additional monorepo info and an examples in advanced-setups.mdx
1 parent 5e302d0 commit b43a351

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ 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 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+
24+
### Getting Started
25+
1126
To set up a monorepo workflow:
1227

1328
1. Find the Workers associated with your project in the [Workers & Pages Dashboard](https://dash.cloudflare.com).
@@ -41,8 +56,8 @@ ecommerce-monorepo/
4156
│ └── notification-service/
4257
│ ├── src/
4358
│ └── wrangler.toml
44-
├── shared/
45-
│ └── utils/
59+
├── packages/
60+
│ └── schema/
4661
└── README.md
4762
```
4863

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

6075
### Example
6176

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`.
77+
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`.
6378

6479
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)