Adding A Dockerfile to the project

Before we can deploy anything to Rancher it needs to be in a docker image so I’ll be asking my VSTS scripts to build a docker image that can then be uploaded to a Docker container/image repository before being deployed to the Rancher server.

To create the Docker image I need a Dockerfile added to the project and I need to also tell my build script to copy it to a location that the release script can access.

First I will create a new folder in my project under src/main called ‘docker’.


To that folder I will add a new file called ‘Dockerfile’. Make sure you get the case right. It is not camel-case and does not have a capital F in the middle of the filename.

In this file I will add what is probably the simplest Dockerfile instructions you have ever seen.


Basically I’m starting with the openJDK Java runtime environment running on Alpine Linux which is a very small distribution of Linux that can run java apps. I then setup my tmp volume, I copy my jar file in to the image, setup what port should be exposed and then tell it how to run the jar file. The resulting image will be about 60Mb plus the size of your jar file.

You will also need to update the build definition so that it will copy the Dockerfile to the artifact store which will be used during the release process. Back in VSTS find your Build definition and open it for editing.


Select the ‘Add Task’ option and select the ‘Copy Files’ task to be added to the build process. Make sure you move it up above the final stage of Publish Artifact and then fill in the source folder and target folder options.

If you haven’t already then make sure you commit the dockerfile to Git and then push the changes to teh VSTS server and run a new build. This will verify that the build process changes have worked.

Tagged with:
Posted in Domino To Spring
%d bloggers like this: