Heroku buildpack to support deployment from subdirectory
Sometimes people use single git repository for multiple related server applications (think of microservices). Such applications reside in subdirectories of the main repo. I found it is not possible to deploy such configurations to Heroku: even if there is a buildpack to use custom Procfile, other problems still exist — e.g. npm install looks for package.json in the root folder only. Long story short, I wrote a Heroku buildpack which allows to use single subdirectory as new project root.
Please find it here: https://github.com/timanovsky/subdir-heroku-buildpack
How to use:
- heroku buildpacks:clear if necessary
- heroku buildpacks:set https://github.com/timanovsky/subdir-heroku-buildpack
- heroku buildpacks:add heroku/nodejs or whatever buildpack you need for your application
- heroku config:set PROJECT_PATH=projects/nodejs/frontend pointing to what you want to be a project root.
- Deploy your project to Heroku.
How it works
The buildpack takes subdirectory you configured, erases everything else, and copies that subdirectory to project root. Then normal Heroku slug compilation proceeds.