heroku-buildpack-monorepo-with-shared-gems

by Bus-com

GitHub Readme.md

Heroku Multi Procfile buildpack

Imagine you have a single code base, which has a few different applications within it... or at least the ability to run a few different applications. Or, maybe you're Google with your mono repo?

In any case, how do you manage this on Heroku? You don't. Heroku applications assume one repo to one application.

Enter the Monorepo buildpack, which is a copy of heroku-buildpack-multi-procfile except it moves the target path in to the root, rather than just the Procfile. This helps for ruby apps etc.

This buildpack was extended by Bus.com to add support for shared gems. The expected repository layout is:

.
+- app1
|   |
|   + Gemfile
|   + Gemfile.lock
|   + Procfile
|
+- app2
|   |
|   + Gemfile
|   + Gemfile.lock
|   + Procfile
|
+- shared
    |
    + gems
       |
       +- common
           |
           +- common.gemspec
           +- Gemfile

During the compile phase, APP_BASE is moved to /app, and shared/gems is moved within /app. Gemfile and Gemfile.lock are modified to move the shared/gems directory around, in case this app references the shared gems.

Usage

  1. Write a bunch of Procfiles apps and scatter them through out your code base.
  2. Create a bunch of Heroku apps.
  3. For each app, set APP_BASE=relative/path/to/app/root, and of course: heroku buildpacks:add -a <app> https://github.com/lstoll/heroku-buildpack-monorepo
  4. For each app, git push git@heroku.com:<app> master

Authors

Andrew Gwozdziewycz apg@heroku.com and Cyril David cyx@heroku.com and now Lincoln Stoll lstoll@heroku.com