Setting up a TravisCI worker locally

In the previous post we've setup the required infrastructure: (Self-made continuous integration with Travis CI) The worker requires a bit more configuration.

Anyway let's create the worker Docker image first. We will create it with the help of the following Dockerfile-travis-worker-2.7.0:

FROM alpine:3.4

ADD /usr/local/bin/travis-worker

RUN chmod u+x /usr/local/bin/travis-worker

VOLUME ["/var/tmp"]

ENTRYPOINT ["/usr/local/bin/travis-worker"]

Then build the Docker image with the following command:

$ docker build -f Dockerfile-travis-worker-2.7.0 . -t worker

This will result in a rather small Docker image.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
worker              latest              2013b5dd3fe3        2 minutes ago       40.1 MB

A first check:

$ docker run -it --rm --user root worker --help
   travis-worker - Travis Worker

   travis-worker [global options] command [command options] [arguments...]



Let's continue with the fine-tuning...

$ export HOST_IP=
$ docker run -d \
    --name travis-worker \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -e "TRAVIS_WORKER_DOCKER_ENDPOINT=unix:///var/run/docker.sock" \
    -e "TRAVIS_WORKER_AMQP_URI=amqp://${HOST_IP}" \
    -e "TRAVIS_WORKER_QUEUE_NAME=android.queue" \
    -e "TRAVIS_WORKER_BUILD_API_URI=http://${HOST_IP}:5000/script" \

Since we want to be able to run Android builds locally we need the TravisCI base image. Travis will look for travis:android.

$ docker pull
$ docker tag travis:android