Skip to content

Instantly share code, notes, and snippets.

@fabiokung
Last active Aug 29, 2015
Embed
What would you like to do?
base Docker image for Heroku Buildpacks
# fabiokung/heroku-buildpack-base/Dockerfile
FROM fabiokung/cedar
RUN mkdir -p /var/lib/buildpack
RUN mkdir -p /var/cache/buildpack
ONBUILD ADD . /var/lib/buildpack
# ONBUILD instructions that all buildpacks need to have
ONBUILD ONBUILD ADD . /app
ONBUILD ONBUILD RUN /var/lib/buildpack/bin/compile /app /var/cache/buildpack
ONBUILD ONBUILD RUN ln -s /app/.profile.d/* /etc/profile.d/
ONBUILD ONBUILD ENV HOME /app
# etc...
# fabiokung/heroku-buildpack-ruby/Dockerfile
FROM fabiokung/heroku-buildpack-base
## this is a minimal Dockerfile that buildpacks could use.
## without it, all the ONBUILD calls that all buildpacks
## need to do would need to be copied here:
#
# ONBUILD ADD . /app
# ONBUILD RUN /var/lib/buildpack/bin/compile /app /var/cache/buildpack
# ONBUILD RUN ln -s /app/.profile.d/* /etc/profile.d/
# ONBUILD ENV HOME /app
# ONBUILD etc...

as a buildpack maintainer

$ git clone https://github.com/heroku/heroku-buildpack-ruby.git  # or any other buildpack
$ cd heroku-buildpack-ruby
heroku-buildpack-ruby $ cat Dockerfile
FROM fabiokung/heroku-buildpack-base

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q ruby2.0
# more stuff specific to this buildpack...

heroku-buildpack-ruby $ docker build -t heroku-buildpack-ruby .
...
Successfully build xpto12345

heroku-buildpack-ruby $ docker inspect heroku-buildpack-ruby
...
        "OnBuild": [
            "ADD . /app",
            "RUN /var/lib/buildpack/bin/compile /app /var/cache/buildpack",
            "RUN ln -s /app/.profile.d/* /etc/profile.d/",
            "ENV HOME /app"
        ] 

as a Heroku app developer

Any ruby app (following heroku conventions) could use that buildpack:

$ cd my-heroku-ruby-app
$ docker build -t my-heroku-app-as-a-docker-container . <<END
FROM fabiokung/heroku-buildpack-ruby
END
Output from the heroku buildpack...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment