Some time ago a friend of mine asked me about my thoughts in CI. I really didn’t know much about the subject so I got to play/fool around with new technologies and this is what I got. I started around Christmas 2014 and a little project came up again and again, the overnight sensation, Docker. In this series of tutorials we will configure a workflow using Docker that will get you started for future projects.
In this series of tutorials you will learn how to install Vagrant to get a standardized development environment and using Ansible to provision such environment. Then we will make a Docker app that will print “Hello World” and a Docker Jenkins server. We will configure that Jenkins server to build, test and upload our Docker app to Dockerhub. If everything runs successfully Jenkins will run Ansible to connect to a AWS EC2 instance and install the new Docker app.
This are all the parts of the series, you can jump as you like.
Part 1: Technologies that we will use and why
I will try to make this tutorials as simple for anyone that wants to start working with this tools. But if you want me to be more specific please leave it on the comments and I will gladly revisit the tutorials.
So first lets start with the technologies I will use and why I use them.
Vagrant enables us to create and configure lightweight, reproducible, and portable development environments. Working with vagrant is a breeze. You just need to install Vagrant and a virtualization product (in my case virtual box) and you are done. You can start any environment you want in mere minutes. You can have your VM configured the way you want in any OS.
So for example, if you are going to start working on a new project you can ask for the vagrant file and just run vagrant up and you will get a VM with everything you need to get working. And you can have as many Vagrant machines as projects. Eliminating the dependency hell you get when working on a lot of projects in the same machine.
We are going to use Vagrant to have a development environment with Linux on which to install Docker and Ansible.
Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates. Ansible is really simple to use and has a lot of modules out of the box. But the main attractive I found over Chef and Puppet was that it only requires SSH to work and no slaves.
I use Ansible to provision Vagrant and to Orchestrate the deployment to AWS. Ansible has a low learning curve and a github like repository of Ansible roles called Ansible Galaxy. So at the end it was a no brainer for me.
We are going to use Ansible to provision the Vagrant box and to deploy changes to the AWS instance.
Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. With Docker, developers can build any app in any language using any toolchain. “Dockerized” apps are completely portable and can run anywhere -- colleagues’ OS X and Windows laptops, QA servers running Ubuntu in the cloud, and production data center VMs running Red Hat.
And if that doesn’t make you giggle and feel butterflies maybe you need to read that last bit again. Docker brought simplicity to Linux containers and in return a lot of popularity and hype. So come on, lets all get in the hype train.
We are going to use Docker to “Dockerize” a Node app that will print “Hello World” and for our Jenkins server.
Dockerhub could be compared as Github for Docker containers. Dockerhub lets us browse, host, share and manage public or private Docker images. It also has an automate build option to test if the Docker container is clean.
Some interesting Docker containers you can find in Dockerhub are the official Docker containers of different projects such as Ubuntu, Node, Redis, Nginx, etc.
We are going to use Dockerhub as our main change repository for our Node “Hello World” app.
Jenkins is an application that monitors executions of repeated jobs, such as building a software project or jobs run by cron. Among those things, current Jenkins focuses on Building/testing software projects continuously and Monitoring executions of externally-run jobs.
The Jenkins server we are going to use is going to be a Docker container from the Official Jenkins repo. This way I can share all the configuration I have done with anyone. Jenkins is a really powerful tool and Docker just made it easier to play with it.
We are going to use Jenkins to build and test our Docker app, upload it to Dockerhub and then run Ansible to run the new Docker container in AWS.
Amazon Web Services (AWS) is a collection of remote computing services, also called web services, that make up a cloud computing platform offered by Amazon.com.
We are going to use AWS as our cloud server. Ansible has a nice way to interact with AWS and you can get a free server for a year if you create a new account.
Well that is it for now. On the next tutorial we will go over installing our development environment with Vagrant and Ansible. Please follow me on Twitter and wait for the next parts in the upcoming weeks. Thank you for reading.