You have a single codebase with multiple NestJS apps as defined in: https://docs.nestjs.com/cli/monorepo
How do you run each on Heroku? You don't. Heroku applications assume one repo to one application.
Enter the NestJS Monorepo buildpack, which updates package.json in the root of your NestJS project by adding the defined app to the scripts
.
- Write a single
Procfile
and enter your command:web: npm run start:prod
- Create a bunch of Heroku apps.
- For each app set
NEST_APP=app name
- For each app run
heroku buildpacks:add -a <app> https://github.com/blubblub/heroku-buildpack-nest-monorepo
- For each app
git push [email protected]:<app> main
- If you already have other buildpacks defined, you'll need to make sure that the heroku-buildpack-nest-monorepo
buildpack is defined first. You can do this by adding
-i 1
to theheroku buildpacks:add
command. - The buildpack works only on Linux and it depends on
jq
being installed (by default already on Heroku-20 stack) - It works by updating package.json and appending your NestJS app to commands. Currently it only updates
build
,start
andstart:prod
commands. - If you change the environment variable
NEST_APP
, you will have to redeploy, as Heroku does not run buildpack in this case.
Dal Rupnik [email protected]