We've been general agnostic about Docker round these parts; the value for setting up complex local development environments is obvious, but the idea of taking these containers to production was a bit more scary (at least to me). However I think the production story is is much more clearly defined now, and with products like Kubernetes, or Amazon's EC2 Container Service, we are finally starting to experiment with using container based packaging to deploy some production services.This post isn't talking about the deployment side of things however, it's rather a little note discussing some experiments we did recently playing with a relatively new Docker feature called multistage builds. (Note: multistage builds requires Docker version 17.05 or later).There's lots of information on the Docker documentation site about multistage builds so I won't go over these details again, rather here I just want to post a link to a little repo we created to experiment with what this workflow might look like.Here's the Github repo in which our simple project was created: https://github.com/thingful/simpleThere's not much to the project, it's just a tiny HTTP server with a couple of endpoints, however it contains a multistage Dockerfile that looks like this:# build stageFROM golang:alpine AS build-envRUN apk -no-cache add build-base bashADD . /go/src/github.com/thingful/simpleWORKDIR /go/src/github.com/thingful/simpleRUN make test && make compile# final stageFROM alpineRUN apk -no-cache add ca-certificatesWORKDIR /appCOPY -from=build-env /go/src/github.com/thingful/simple /app/ENTRYPOINT ./simpleEXPOSE 8080Looking quickly at the above you should be able to see that we run our tests and compile our binary in the initial build stage, then we copy this generated binary into a new container to generate our final artifact (for details on the test and compilation steps please see the Makefile in the root of the repo).What I liked about this:The multistage syntax is clean and I think clearThe final built image is indeed nice and small - this tiny server produced an image of around 10MB (it could have been smaller probably if we'd have used the scratch container for the final stage, but that would have required more hacky manoeuvres to handle things like SSL cert bundles).What I wasn't so sure about:In the Dockerfile above I inserted a test step directly in just before running the compilation task, this was fine for this little toy example but that might be annoying in larger projects where running the full test suite might take a while.In relation to that I'm not sure if there would be a way of running just the tests without necessarily building the final container or more generally I don't think there's a way of getting inside the build stage container should you wish to. Maybe that's a foolish thing to want to do - I don't know.As always any comments or feedback would be gratefully received.