Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfnico/b2609bee3911e8890f09 to your computer and use it in GitHub Desktop.
Save tfnico/b2609bee3911e8890f09 to your computer and use it in GitHub Desktop.
Building and pushing docker images to GiantSwarm from your existing jenkins
  • Create a server to work as a Jenkins slave (implying you have an existing Jenkins) on DigitalOcean or whatever you use for getting servers up and running.
  • Install Ubuntu on it, and Java for running the Jenkins slave (current openjdk 7 should work)
  • Create a jenkins user, add a authorized_key that the Jenkins master can use for SSHing to it (see Jenkins docs for more info)
  • Install the latest docker (see Docker docs for info)
  • Add user jenkins to the docker group
  • Do sudo su jenkins, and (with your username/password)
    docker login
  • Set up the slave on Jenkins master (new slave, enter hostname, username 'jenkins', provide ssh-key, etc)

Now you can build an image and have it pushed to GiantSwarm.

    docker build --no-cache=true -t .
    docker push
  • Execute it, wait a few minutes and your image will be ready and waiting in the GiantSwarm registry.

Note that you may want to leave out the --no-cache-true if you can guarantee that the build is deterministic (no snapshot dependencies, etc). It will speed up the build a lot.

Also, I don't like how the todoapp-spark installs a bunch of build-tools into the container which is meant for just running a java application. If you have an existing Maven repository in your infrastructure, you probably want to deploy the Java application into it separately, and then pull it into the Dockerfile like this:

FROM dockerfile/java:oracle-java8 
RUN wget -O todoapp-1.0-SNAPSHOT.jar --user=thomas --password=secret '' 
CMD ["java", "-jar", "todoapp-1.0-SNAPSHOT.jar"]
Copy link

luebken commented Dec 11, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment