Jenkins on Docker for .NET projects

A big portion of last year I’ve spent building accelerators for a Sitecore solution scaffolding and deployments aside from production projects. All this work was done for VMs created in a cloud managed via OpenStack.
Using PowerShell DSC we were able to easily setup single machine local sandboxes as well as multi-server environments. However, provisioning VM and then configuring them is still less than ideal for deployment of an application. What I was really waiting for is a release of a windows containers.
Finally, they arrived closer to the end of last year and few month later I was able to try them out. So I’m going to start describing what I’ve ended up creating, keeping in mind that tweet from last year:

The reason why I was waiting for windows containers is quite simple. A container technology provides you with a possibility to package your application and make sure that configuration this it will use will be absolutely identical on all environments. It doesn’t really matter if you are running a container on your local machine or in a cloud, and that is a beauty.

In addition to that, you have a very easy way to scale your application as a creation of a new container, that already has your application and is ready to go takes less than a couple minutes (plus whatever you put into a vanilla Sitecore to make it start slower :).

You do not need to reconfigure a clean machine – just provide valid connection strings to databases and you are good to go. This could be done via environment variables and a tiny startup script or even simpler – automatically linked hosts via docker compose (or Swarm, or Kubernetes).

It is possible to continue this list for quite a while, but hope you start to feel this pure DevOps joy 🙂

Jenkins

As some samples of Sitecore in docker are already available on GitHub I used them as a basis, but my interest in end-to-end deployment solution with should include a continuous integration as a must-have element.

Tools providing good dotNET support like AppVeyor are really nice to work with but they only provide SaaS offering. TFS is something that I prefer not to work with unless I’m forced to (new build system make a situation a bit better but still). I end up using Jenkins as it is absolutely free, widely used and support tons of different plugins.

jenkins _ Sitecore Build.V2 Multi-Branch - Google Chrome 2017-04-28 23.34.51

Actually, with recently released Blue Ocean it gets a nice facelift, multibranch support which is good for feature branch development and ability to drive CI configuration with Jenkinsfile stored in your source control.

What is included

Jenkins image on a GitHub includes master and slave configurations of Jenkins. Both images are build based on openjdk:windowsservercore images available on DockerHub. The reason to do it on Windows images is that setup of a Docker cluster with multiple platforms is quite complicated to run on single VM or your PC, but I’m planning to explore this later with Kubernates or Swarm.

On on top of this for Master, I’m installing Jenkins itself, Git client (as you would need it to check the content of branches and trigger feature branch build).

The Slave configuration is a bit more complicated, as it includes following things:

  • Download Jenkins zip and extract slave from it
  • Install dotNet 4.5 features
  • Install MsBuild 14
  • Install Nuget
  • Install MsBuild Web Targets (this allow to avoid Visual Studio installation on slave machines

  • Install Git
  • Install NodeJS
  • Install Jetbrains Static Code Analysis
  • Install NUnit & XUnit

In addition to that, each setup will have its own start-up file that will start Java and load corresponding jar file in it. The master configuration will also check plugins.txt file and install all plugins listed there.

Those images are the basis and are further inherited by Sitecore ones. In my case, I’m adding TDS as we are using it internally and also a default configuration to Jenkins Master. This default configuration includes jobs that we are usually setting up for Sitecore.

 

Where to find?

You could find the source code of base images on GitHub https://github.com/asmagin/jenkins-on-windowsservercore or on DockerHub https://hub.docker.com/r/asmagin/jenkins-on-windowsservercore


Follow me on twitter @true_shoorik. Would be glad to discuss ideas above in comments.

Jenkins on Docker for .NET projects

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s