Way to remove build tooling.
Many containers build code in some fashion during their construction. However, for convenience reasons build tools are often left inside the resulting container image. This is not ideal. It would be nice if box provided a convenient way to remove the excess layers.
Some ways of accomplishing this that I can see are:
- Build an artifact in one container but move that layer to be based on a different image at the end -- effectively omitting intermediate layers.
- Allow a way to flatten an image with a whitelist directory. E.g. "Flatten all these layers, and only keep files from this particular directory."
- Allow some layers to be specified as ephemeral. These layers could be removed at the end of a build with parents relinked appropriately by box.
https://github.com/erikh/box/blob/master/image/image.go is a start at creating a position-independent layer management system for docker images; once this is fleshed out a bit more I think a lot of this stuff gets easier.
Thinking purely about the language used to describe this, this could preserve all files specified in the glob after the build instructions inside the block complete. Is this what you're after?
artifact "/tmp/**/*.go" do
copy "sourcecode", "builddir"
inside "builddir" do
run "some build stuff"
end
end
@schancel did you ever get a chance to look at this yet? We added a skip function which does most of what you're describing here.