Brooklyn is a large project with a lot of dependencies. I wanted to compile it, but I also wanted to remove all traces of the project when I was done experimenting. I used Docker to accomplish this goal.

See the files below at

First, I created a Dockerfile to load java, maven, and clone the repository.

$ cat Dockerfile
FROM ubuntu:14.04
MAINTAINER David Medinets 

# Install Java

RUN apt-get update && \
  apt-get install -y software-properties-common && \
  add-apt-repository -y ppa:webupd8team/java && \
  echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections && \
  echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections && \
  apt-get update && \
  apt-get install -y oracle-java8-installer

ENV JAVA_HOME /usr/lib/jvm/java-8-oracle

# Install Maven
RUN echo "deb precise main" >> /etc/apt/sources.list && \
  echo "deb-src precise main" >> /etc/apt/sources.list && \
  apt-get update && \
  apt-get -y --force-yes install maven3 && \
  rm -f /usr/bin/mvn && \
  ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn

RUN mkdir -p /root/.m2

ADD settings.xml /root/.m2/settings.xml

# Clone the brooklyn project
RUN apt-get install -y git
RUN git clone

WORKDIR /incubator-brooklyn

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

There is one twist - that settings.xml file. It's used to connect to a Docker-based Artifactory image later.

Then I created a script to build the image.

$ cat
sudo DOCKER_HOST=$DOCKER_HOST docker build --no-cache --rm=true -t medined/ .

Also a script to run the image.

$ cat

# Make sure that Artifactory is running.
ARTIFACTORY_COUNT=$(docker ps --filter=status=running | grep artifactory | wc -l)
if [ "${ARTIFACTORY_COUNT}" != "1" ]
  echo "Starting Artifactory"
  docker run --name "artifactorydata" -v /opt/artifactory/data -v /opt/artifactory/logs tianon/true
  docker run -d -p 8081:8081 --name "artifactory" --volumes-from artifactorydata  codingtony/artifactory

IMAGEID=$(docker ps -a |grep "" | awk '{print $1}')
if [ "$IMAGEID" != "" ]
  echo "Stopping $IMAGEID"
  IMAGEID=$(sudo DOCKER_HOST=$DOCKER_HOST docker stop $IMAGEID | xargs docker rm)

  docker run \
    --link artifactory:artifactory \
    -i \
    -t medined/ \

In the run script, an Artifactory image is started if one isn't running. Artifactory lets you compile Brooklyn over and over with needing to download the dependencies more than once.