- 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
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.
- New Job, freestyle
- As source, use your own repo or for example: https://github.com/giantswarm/todoapp-spark
- Add shell (adapt to your own registry prefix):
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"]