I forget to say that several repositories, where I’m not the owner, will need to build images with s2i. I really wonder how I will be able to make that working.
This drone configuration works for me on official helm chart.
Note that I have to use volumes on every pipelines to make with docker layer caching working.
But I’m still stuck at no space left on device issue. I’m going to stop using k8s method for now and use https://autoscale.drone.io/ instead.
This is a “trick”, I only prepare a Dockerfile that makes exactly what s2i does: take an image, build sources with “assemble” and set the command to “run”.
Note that the image is now well built and pushed to the private registry (only accessible through Kubernetes cluster, I didn’t tried to use service name but it should work)
That is very simple, maybe more adapted to my workflow. But, anyway, I will take a look on your solution that can help me a lot later. One more time, thanks a lot !
EDIT looks like you figured out how to get the Docker plugin working. The below explanations may still be useful to understand why the various configurations previously attempted did not work.
NOTE the recommended approach to building and publishing docker images is using the plugins/docker plugin, as you have done in your updated example. This can be done without requiring trusted mode and is therefore more safe. Other options that require trusted mode are of course viable alternatives, but trusted mode inherently introduces security concerns since it effectively grants the build unrestricted root access to your host machine.
One issue with your example is that there is no docker daemon running inside plugins/docker because you are overriding the default plugin entrypoint when you set commands. If you are going to use this plugin image, it should be used in the following manner http://plugins.drone.io/drone-plugins/drone-docker/
I also tried “docker” image and “docker:dind”
Here are some root causes for the error you described:
the docker image does not start a docker daemon
the docker:dind starts a docker daemon, but the image requires privileged: true
the docker:dind starts a docker daemon as the entrypoint, but when you set commands you are overriding the default container entrypoint, and as a result no docker daemon starts.
My repository is “Trusted” and I set up drone with my admin account that is the user on gitea which is mine.
setting a repository as trusted is the first step. The second step is that you need to run containers in privileged mode, using privileged: true
What I really need, actually, is to create a plugin that uses “s2i” command - this command needs a docker daemon somewhere to pull base image, and to push resulting image.
What I did is a “trick” to avoid that command usage, but s2i allows several options.
I already tried to build a “s2i” image using “FROM plugins/docker” but it seems that I’ve got many problems to override it…
My plugin Dockerfile makes:
FROM plugins/docker
ENV S2I_VERSION=1.1.14 \
S2I_GITCOMMIT=874754de
RUN set -xe; \
wget -O - https://github.com/openshift/source-to-image/releases/download/v${S2I_VERSION}/source-to-image-v${S2I_VERSION}-${S2I_GITCOMMIT}-linux-amd64.tar.gz | tar -C /usr/local/bin -zxf - ./s2i
ADD s2ibuild.sh /usr/local/bin/s2ibuild.sh
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/usr/local/bin/s2ibuild.sh"]
you need to set privileged: true for your pipeline step. The plugins/docker image is whitelisted and automatically run in privileged mode, but your custom plugin will not.
where are you starting the docker daemon? If you look at plugins/docker source code you will see that we start the docker daemon in the Go code [1]
Please note that you can test plugins locally [2] which makes it easier to debug them and triage these sorts of issues. I recommend studying the docker plugin source code [3] more closely which may help you proceed.
This is what I didn’t undertand until I’ve taken a look on the drone-docker sources (just minutes before your answer )
This is, IMHO, one point that Drone is missing… I’m pretty sure you’re very busy and you will not create such whitelisted plugin. But if one day you want to make it possible, please consider s2i to be a very useful plugin. I know Go and I probably can build such plugin myself, but I am running out of time (and I don’t know the structure as well as you, I will spend so much more time than you)
Even if I was able to find time to develop such of plugin, it will not be whitelisted and my teammate will not be able to activate it (no privilege) - so I have to use my workaround for now. It’s usable, that’s the essential goal
S2I would be very interesting to avoid my teammate to overwrite Dockerfile, and let a “base image” to assemble the image. The project sources doesn’t need to have a Dockerfile. It’s a bit more secured and it can make incremental build as well.
It’s not so bad, as I’m able to fake the s2i build by generating a Dockerfile, I will be able to leave that for now.
PS: Drone is very impressive, it works very well now in Kubernetes, and I’m very happy to use it. This little worry does not spoil my enthusiasm to use it at all.
I now use “plugins/docker” as base image, and I can start docker daemon without privilege mode (I whitelisted my plugin)
I can now do that:
kind: pipeline
name: default