Solomon Hykes

Heroku buildpacks on Docker

Hi all,

Today’s hack day turned into an improvised collective workshop, and the result is that you can now build and run Heroku apps on Docker 🙂

# DOCKERIZING YOUR HEROKU APP

Here’s how to dockerize your heroku app using the official Node.js buildpack:

## Step 1: Add a Dockerfile to your app

Make sure to use the buildpack as a base layer.

Here’s an example: https://github.com/shykes/vr_node_example/blob/master/Dockerfile

## Step 2: Build it!

Use the docker-build contrib script (soon to be replaced with “docker build”!)

$ curl https://raw.github.com/dotcloud/docker/v0.2.1/contrib/docker-build/docker-build > docker-build
$ python docker-build < Dockerfile | tee build.log
$ BUILD=$(tail -n 1 build.log)
$ docker history $BUILD
$ docker tag $BUILD shykes/vr_node_example

## Step 3: Run it

$ APP=$(docker run -d shykes/vr_node_example)
$ curl localhost $(docker port $APP 5000)

# DOCKERIZING A BUILDPACK

And here’s how to dockerize a buildpack:

## Step 1: Add a dockerfile to your buildpack

Make sure it includes all the system dependencies. Here’s an example: https://github.com/shykes/heroku-buildpack-nodejs/blob/master/Dockerfile

(Note that I forked heroku’s official buildpack, in case the maintainer is interested in a pull request).

## Step 2: Build it!

$ curl https://raw.github.com/dotcloud/docker/v0.2.1/contrib/docker-build/docker-build > docker-build
$ python docker-build < Dockerfile | tee build.log
$ BUILD=$(tail -n 1 build.log)
$ docker history $BUILD
$ docker $BUILD shykes/my-buildpack

## Step 3: Publish it

$ docker push shykes/my-buildpack

Your buildpack is now available as a base layer for dockerized heroku applications (See “dockerize your heroku app” above).

Give it a try on other buildpacks, let me know if it works!

, ,

Solomon Hykes

Heroku buildpacks on Docker


Leave a Reply

Get the Latest Docker News by Email

Docker Weekly is a newsletter with the latest content on Docker and the agenda for the upcoming weeks.