Skip to content

Instantly share code, notes, and snippets.

@tfnico
Last active August 29, 2015 14:11
Show Gist options
  • 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 https://registry.giantswarm.io
  • 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 registry.giantswarm.io/acmecorp/exampleimage .
    docker push registry.giantswarm.io/acmecorp/exampleimage
  • 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 'https://repo.ourcompany.com/nexus/service/local/artifact/maven/redirect?r=snapshots&g=com.ourcompany&a=todoapp&v=LATEST&e=jar' 
CMD ["java", "-jar", "todoapp-1.0-SNAPSHOT.jar"]
@luebken
Copy link

luebken commented Dec 11, 2014

nice

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