Building an image that contains drone-cli

I was trying to address the problem of triggering downstream builds in the simplest way I could think of. I built a small docker image containing the drone-cli.

# Dockerfile
FROM  alpine

RUN apk add --update \
      && apk add curl \
      && rm -rf /var/cache/apk/* \
      && curl | tar zx
      && install -t /usr/local/bin drone

COPY ./ /
ENTRYPOINT ["/bin/sh","/"]

And then my script would simply get the most recent build and start it again:

build_number=$(drone build last $REPOSITORY | head -n 1 | cut -d " " -f 2)
echo "Rerunning the most recent build #$build_number now."
drone build start $REPOSITORY $build_number

This is a rather blunt approach, but it seemed to me that it wold work just fine. In fact, when I pass the container ENV vars locally, it runs like a champ.

But, when I put it in my .drone.yml to run, it pulls the image and fails reporting: ERROR: Error response from daemon: readdirent: not a directory. After googling and coming up with very little, I started removing lines of code until I found what appears to be causing the error.

This step in my docker build, while working locally, will fail when run by drone: curl | tar zx

Any idea why this might be? Or how to get around it?

I think I discovered the cause of the problem. It seems like docker is mounting a volume called “drone”, which is the same thing that the file was trying to untar to. :slight_smile:

There is also an existing plugin for this:

Also note that Drone downloads were moved to GitHub and are distributed using GitHub releases