We want to be able to do the following:
- Upon merge-and-submit, run docker-pkg in CI and build the image, then publish it
The only technical difficulty we encounter if we want to do this is... we need to be able to connect to the docker daemon from within a docker container, which AIUI isn't allowed in CI for obvious reasons.
The approach I want to take is to add support for an alternative build tool so that we can build the image within a container without the need to call the docker daemon. The best tool to do so as far as I can tell is kaniko.
So my idea would be to allow docker-pkg to output its dockerfiles and build contexts under a single source directory, then run kaniko to build and publish the various images.
There are two ways of implementing this:
- Add a separate command to docker-pkg called kaniko-build with completely separate logic. Basically we'd use the imageFSM only to find the build chain and the initial image status, and possibly to get back from kaniko the result of the build
- Add a separate implementation of the Image class and the imagfsm class for kaniko builds, abstracting whatever is common between implementations, then make using kaniko a configuration switch and support build as the same command as before.
I think I'll pick the latter.
An additional difficulty is represented by the fact we want to run everything inside a single docker container, that we will have to build ourselves as kaniko is only supposed to be run inside the official google docker images, which we can easily reverse-engineer though.