Heroku buildpack to support deployment from subdirectory

Alexey Timanovskiy
1 min readJun 16, 2017

--

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:

  1. heroku buildpacks:clear if necessary
  2. heroku buildpacks:set https://github.com/timanovsky/subdir-heroku-buildpack
  3. heroku buildpacks:add heroku/nodejs or whatever buildpack you need for your application
  4. heroku config:set PROJECT_PATH=projects/nodejs/frontend pointing to what you want to be a project root.
  5. 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.

--

--