kedge
kedge copied to clipboard
[EPIC] create a command for creating docker images via kedge
on the fabric8-maven-plugin we have to handle the case that:
- the user is running on kubernetes or OpenShift with access to the docker socket; so perform docker builds via the docker CLI tool using a Dockerfile (or a default ONBUILD Dockerfile for various standard languages like node / go / dot net etc). e.g. https://github.com/fabric8io/fabric8-jenkinsfile-library/blob/master/golang/ReleaseAndStage/Jenkinsfile#L12-L13
- the user is running on OpenShift without access to the docker socket; then either
- use a S2I binary build (generating the BuildConfig on the fly) and POST the tarball of the binary to use
- use a docker build in OpenShift (generating the BuildConfig on the fly)
It might be nice to add this logic into kedge so that folks can build images on kubernetes or openshift using other languages/frameworks/build tools other than Java + maven + fabric8-maven-plugin
. Then after a language specific build tool (make / npm / grunt / gulp / gradle / whatever) has created the binary or artefact(s) and we just need to take the generated file(s) and create the docker image using whatever strategy suits the current cluster.
So something like
$ kedge build --dockerfile=Dockerfile myuser/myimage:${VERSION} ./build/mybinary
Running on OpenShift so defaulting to using S2I build
Generated foo-s2i
Building....
Image created: myuser/myimage:1.2.3
Starting with vanilla support for running the necessary docker
or oc
CLI tools would be a good start.
Later on it might be nice to also support the Google Container Builder too: https://cloud.google.com/container-builder/docs/ for folks using kubernetes
I would like to take a stab at the build story for kedge!
This needs to be discussed though, with one approach at a time.
@surajssd We probably will have to break this task into smaller tasks before you start implementing it.
yeah, we could separate out the different strategies...
- lazily create if required a S2I binary build on the fly (like fabric8-maven-plugin's build goal does if using OpenShift)
- use the OpenShift Docker binary build strategy if its available (usually its not) ;)
- use the docker socket if its available (e.g. on kubernetes) and use the
docker build
CLI to do it - use Google Container Builder
- if buildah is ever usable inside a build pod in openshift/kubernetes (again not for a while by the sounds of it) - we could use that too https://github.com/projectatomic/buildah