Source

Update: Can't recommend using Travis for this kind of CI, it turned out very flakey once I used actual images rather than the simple echo tool images. Builds would sometimes timeout after 15mins of hanging, either on building images or attaching. Not sure why, but I imagine Travis isn't really intended for loading multiple containers ~400meg in size (JVM+deps).

Example using Docker to create an nginx image and dropwizard image, then link them together so nginx acts as a reverse proxy for Dropwizard. Can be extended to link together multiple Dropwizard applications. Uses Docker Compose to create and configure the images.

terminal gif

Requires:

To run locally:

gradle run
# ./go

To run containers:

gradle buildJar
docker-compose up -d

# retrieve your docker host IP from boot2docker
boot2docker ip

# curl dropwizard/nginx containers using docker host IP
curl http://192.168.59.103:8080/hello
curl http://192.168.59.103:8090/hello

Details

The docker-compose.yml file configures the two images, creating a dropwizard container and linking it to an nginx container. With the link in place, docker creates a hosts entry for the dropwizard container which can be used in the nginx config volumes-nginx-conf.d/default.conf when setting up the reverse proxy.

Based Travis build on moul/travis-docker.

Using a client image to test the nginx/dropwizard images, as you cannot curl directly from Travis CI. Ideally, once Travis has started the containers in demonised form I would run a test script which uses curl/selenium to test the various endpoints exposed from nginx and hit dropwizard. If this needs to be done via the client then the results of the test can be output to a write-enabled volume and parsed to determine build result, as docker-compose will always return exit code 0 if the containers run.