Heroku open-sourced the ruby library that compiles an application with a buildpack and create a slug archive : https://github.com/heroku/slug-compiler/