Heavily inspired by flynn/slugbuilder, ddollar/mason and phusion/baseimage-docker
Slugs are compressed and pre-packaged copies of your application optimized for distribution to the Heroku dyno manager. When you git push to Heroku, your code is received by the slug compiler which transforms your repository into a slug. Scaling an application then downloads and expands the slug to a dyno for execution. - from Heroku docs
- Extra environment variables
- slug compilation and compression
- slug upload
- Ping notifications with: slug size, errors, compile time
First, you need Docker. Then you can either pull the image from the public index:
docker pull lxfontes/slugbuilder
Or you can build from this source:
git clone https://github.com/lxfontes/slugbuilder
cd slugbuilder && make
The easiest way to get started, is to simply pipe your application and save capture the output using:
git archive master | docker run -i -a stdin -a stdout lxfontes/slugbuilder > myslug.tgz
You can also pass parameters to slugbuilder as:
- slug output path (default is "-" / stdout)
- upload url (default is blank)
- reporting url (default is blank)
Not binding to stdout as we don't need to save the slug locally:
git archive master | docker run -i -a stdin -a stderr lxfontes/slugbuilder - http://fileserver/path/for/myslug.tgz
Not binding to stdout as we don't need to save the slug locally:
git archive master | docker run -i -a stdin -a stderr lxfontes/slugbuilder - http://fileserver/path/for/myslug.tgz http://reportserver/track
Saving slug locally and reporting:
git archive master | docker run -i -a stdin -a stderr -a stdout lxfontes/slugbuilder - '' http://reportserver/track > myslug.tgz
To speed up slug building, it's best to mount a volume specific to your app at /tmp/cache
. For example, if you wanted to keep the cache for this app on your host at /tmp/app-cache
, you'd mount a read-write volume by running docker with this added -v /tmp/app-cache:/tmp/cache:rw
option:
docker run -v /tmp/app-cache:/tmp/cache:rw -i -a stdin -a stdout lxfontes/slugbuilder
Environment variables defined are parsed from 3 locations:
- buildpack specific
.env
file on git repo/tmp/cache/env
- which is usually mapped to a long-term storage on the docker host
These will be combined and appended to .profile.d/99-extra.sh
and made available to application runtime.
As you can see, slugbuilder supports a number of official and third-party Heroku buildpacks. You can change the buildpacks.txt file and rebuild the container to create a version that supports more/less buildpacks than we do here. You can also bind mount your own directory of buildpacks if you'd like:
docker run -v /my/buildpacks:/tmp/buildpacks:ro -i -a stdin -a stdout lxfontes/slugbuilder
The Docker image here is based on cedarish, an image that emulates the Heroku Cedar stack environment. All buildpacks should have everything they need to run in this environment, but if something is missing it should be added upstream to cedarish.
BSD