How to deploy monorepo with using library on Heroku

Viewed 298

I have a repository on Github with monorepo project which includes library written with using NestJS framework. Structure like below:

MAIN FOLDER:
- apps:
-- projectA
-- projectB
- libs:
-- libraryA
-- libraryB

ProjectA and ProjectB using both of the libraries from libs folder,

How to deploy on heroku projectA and projectB so that they use resources from my libraries?

And another question,in package.json I ahve this command to build projectA after deployment on heroku:

"start": "node dist/apps/projectA/main.js",

how to deploy projectB when in this package.json path to the main.js must be different?

Thanks for any help!

1 Answers

I was looking online for the solution, but did not find one. So I created a new Heroku Buildpack.

So basically what I do is update the package.json scripts with additional app being set as NEST_APP from Heroku config variables. This is done before nodejs buildpack is run, which then executes the scripts as usual, defined in Procfile.

Most of the time start:prod is executed on Heroku, which has a specific distribution folder, so I also change the folder location for the script.

Buildpack available on GitHub: https://github.com/blubblub/heroku-buildpack-nest-monorepo

Related