How to deploy a monorepo like Turborepo on Cloudflare Pages

So currently we have our frontend on vercel but It's not possible for us to deploy a monorepo under one git repo using vercel, and I found out that it's possible to deploy using cloudflare with mutiple cloudfalre pages (https://www.emmanuelgautier.com/blog/monorepo-publish-with-cloudflare-pages)
Emmanuel Gautier
Publish multiple projects on a Monorepo on Cloudflare Pages
All the tooling provided by service providers is great and makes the developer's life much easier. Usually, those providers connect one git repository to an application. It works fine but it is not so easy when you work on a monorepo or if you want to make multiple deployments for more than one locale from only one source code.
12 Replies
RADNA
RADNAOP16mo ago
Here's the article But I'm still having problems understanding how to do this Any help would be greatly appreciated!
Ray
Ray16mo ago
apps/app1 -> build script -> output -> deploy coludflare ( wrangler pages deploy ) apps/app2 -> build script -> output -> deploy vercel ( vercel build --prod && vercel deploy --prebuilt --prod ) What you need is to make some CI scripts, through custom build, deploy commands, you can deploy anywhere.
RADNA
RADNAOP16mo ago
sorry some confusion there so We have out frontend on vercel already and our backend is a monorepo and we want to deploy that using cloudflare we have setup a basic ci/cd process using github actions but it says that we haven't setup the pages on cloudflare and when we tried to create multiple microservices using cloudflare pages we couldn't create another one using the same repo ohh I see So a ci/cd script for each application works would it be possible if you could provide an example?
Ray
Ray16mo ago
Yes, the script for each project can be different.
simpson
simpson16mo ago
We use an NX monorepo and Github Actions to deploy a bunch of apps to Cloudflare Pages using Direct Upload, it works great
RADNA
RADNAOP16mo ago
can you share an example, if possible?\ @simpson2
simpson
simpson16mo ago
I can’t share the whole project but I can tell you it is pretty vanilla NX setup with 3 NextJS apps, configured with GitHub actions to direct upload to Cloudflare. We just followed the basic docs for both (hats off to both team for having great documentation) You make X projects in Cloudflare to map the builds to
RADNA
RADNAOP16mo ago
but cloudflare doesn't seem to allow a single repo to create multiple projects? I have a sample app setup on cloudflare and when I try to create another it says that the repo is being used already
simpson
simpson16mo ago
You won’t build on Cloudflare, all your builds will happen in GitHub Actions and then upload to your individual Cloudflare Pages projects
simpson
simpson16mo ago
Cloudflare doesn’t support monorepos but it easy to configure GitHub Actions https://docs.github.com/en/actions
simpson
simpson16mo ago
Direct Uploads · Cloudflare Pages docs
Direct Uploads enable you to upload your prebuilt assets to the Pages platform and deploy them to the Cloudflare global network. This guide will …
simpson
simpson16mo ago
So think of it as you commit your code to GitHub -> GitHub Actions builds whatever your app is -> GitHub Actions then uploads your compiled app to Cloudflare Pages through Direct Upload (kinda like ftp)
Want results from more Discord servers?
Add your server