enqueue ONBUILD instructions from multiple ancestors

I'm sorry for the lack of a better name for this feature request.

I want heroku buildpacks to be docker images. That way, Heroku apps could be built with Docker, generating both a valid docker container to run the app, and a valid Heroku slug that could be deployed to Heroku.

While playing with the idea, I found that all buildpacks will have a common set of ONBUILD instructions. Eg.: all buildpacks need to run their bin/compile against the app source code.

Initially I thought that chaining ONBUILD (#4244) in a base image for buildpacks could be a solution to avoid all buildpacks having to C&P a piece of shared Dockerfile:

Using Heroku buildpacks as Docker images to build apps.

Discussions on irc (#docker-dev) made me realize that ONBUILD ONBUILD may not be very flexible. It would only allow buildpack-base -> buildpack -> app hierarchies. Composing buildpack images (a.k.a. buildpack-multi) would not be possible that way (eg.: buildpack-base -> buildpack-ruby -> buildpack-pgbouncer -> app.

Some alternatives that were proposed:

  • Introspection: allow buildpacks to call docker --introspect --change "ONBUILD RUN ... and similar things during build. That way buildpack images could enqueue their ONBUILD commands and propagate ONBUILD commands from their ancestors.
  • Chained docker build invocations, as suggested by @proppy. It's not clear to me though how it would enable the use case I originally mentioned (Heroku buildpacks as docker images).
  • INCLUDE: Proposal: Dockerfile add INCLUDE #735. With it buildpacks could just add the shared set of commands to their Dockerfiles.

Any other ideas? I'm happy to help with code and PRs once we settle on a design.