Roll your own Heroku slugs (part 2) – without a buildpack
My last post was about self building heroku slugs on your own machine.
This has been our approach until the last month or so, but now we have changed.
We have created a new command line tool called cs-builder that builds slugs but doesn’t use a buildpack. The reason we do this: speed. The buildpack we use (the scala buildpack) was really inefficient, as it would rebuild the project from scratch even though the project had already been built by the previous continuous integration steps like test and integration test. This tool makes use of any assets from previous build steps for slug generation.
It has a number of commands, but the most interesting ones for this post are:
cs-builder build-from-git --branch=BRANCH --git=GIT --build-assets my-binaries
Which builds your project from your git repo and archives the build-assets with a commit hash.
cs-builder git-slug --branch=BRANCH --git=GIT --template=the_slug_template
Which merges your archived build assets with whichever slug template you’re using. It comes with 2 preinstalled templates for node and the jdk 1.7 and it’s easy to add your own.
cs-builder heroku-deploy-slug --branch=BRANCH --git=GIT --heroku-app=HEROKU_APP
Which deploys the slug using the heroku release api.
Using this tool has greatly reduced our build/slug times. We were averaging 6 minutes using the heroku buildpack – now it takes 1 minute.
The full details are in the project: https://github.com/corespring/cs-builder. Also this command line tool is inspired by the following article: https://devcenter.heroku.com/articles/platform-api-deploying-slugs.