#How to deploy multiple workers (≠ domains) from the same repository (multi-tenant app)

11 messages · Page 1 of 1 (latest)

sly aurora
#

Hello,
I would like to get a second version of an app i'm deploying on another domain, for another client.
The repository would be the same (same code, same branch) I would like to get other environnement variable for this client

And each time I would merge pull request on main, it would trigger a deployment using the cloudflare integration to both of the workers

Thanks

scenic kettle
#

you can create wrangler config for each tenant and then deploy it using npx wrangler deploy --config tenant1.jsonc

#

does all tenants use the same bindings?

sly aurora
#

yes they'll use the same binding; I'd rather use the git integration automatic with cloudflare when I merge PR on main branch.
Each time i tried deploying the project using npx wrangler deploy it ended up using dev env variable in prod and broke the prod twice
is there a way to keep using this integration

scenic kettle
#

if they all use the same bindings then why don't you just attach multiple domains to the same worker?

sly aurora
#

because the environment variable needs to be different, mainly for NEXT_PUBLIC_APP_URL (the domain on which the app runs, so emails are generated with the correct links)

scenic kettle
#

they support monorepos so you could have each tenant config in they own directory and configure that, not sure if that would work just thinking out loud

sly aurora
#

nope, thank you after reading it their example is about "prod" and "preview" environement, but then that should work with "client1" / "client2", just hoping the git integration will trigger a deploy on both 🤞

scenic kettle
#

you can have each worker points to the same repo so it will start builing on any change there and change each worker build command to use diferent config file

#

or maybe you could use tenants as environments but you would still need to change the build command to use the correct environment