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 http://downloads.drone.io/release/linux/amd64/drone.tar.gz | tar zx
      && install -t /usr/local/bin drone

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

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

# entrypoint.sh
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 http://downloads.drone.io/release/linux/amd64/drone.tar.gz | tar zx

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

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:
http://plugins.drone.io/drone-plugins/drone-downstream/

Also note that Drone downloads were moved to GitHub and are distributed using GitHub releases https://github.com/drone/drone-cli/releases

Cheers