Alambique Ancora: Docker

I talked with my brain this week and the Alambique Ancora decided start the development by purchasing module. This is one of crucial modules of production process, because determines the quality of final product. Also, ensures that the suppliers are qualified to delivery the raw material.

But, we’ll talk about purchasing module with more details in the next post. Now, it’s time to talk about a great tool that will to support our development, testing and production infrastructure.

Docker

One of most interesting tools that I’m working currently is Docker. Docker is an open platform that allows developers to build, test and run distributed applications. This tool works with containers and allows multiple containers to run in a single machine sharing the OS kernel and making RAM and other resources usage more efficient.

Docker differs from virtual machines architecturally. While virtual machines needs a entirely guest OS, Docker containers share the OS kernel but run in an isolated process. This make the containers much more efficient and portable. Also, they are not tied to any specif infrastructure, running on any computer, infrastructure or cloud.

Another cool thing is the ability to create default images of the containers for development and testing, avoiding the classic “works on my machine” phrase. So with Docker, we’ll make our infrastructure simpler and run AA application stack smoothly.

For now I’ll focus on the development environment. But during our progress, I’ll give more details about extra configurations related to Docker.

Development environment

To begin with development, we need our environment configured. First of all, we need to install the Docker toolbox. You can start here. When this step is complete, we need to set up the environment variables below to Docker work properly.

set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_MACHINE_NAME=default
set DOCKER_TLS_VERIFY=1
set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default

For some obscure reason — not yet identified by me — default installation won’t work without this variables on Windows. You can set through terminal or create this variables in the system properties window and never worry about it again. There are another ways, but let stay just with this two. So, with this steps completed, it’s time to install the chosen database for AA services, MySQL.

One of the greatest things about Docker is the hub. A lot of images are available for use just a command line of distance. So, to create our database container, we need this line below.

docker run -p 33306:3306 --name aa-mysql -e MYSQL_ROOT_PASSWORD=a1b2c3d4 -d mysql:latest

When executed, the Docker toolbox will search for the latest version of MySQL online and then will cache it. It will create a container named aa-mysql specified by -name parameter. The -p parameter expose the port 33306, which is mapped to default 3306 and will be used by our microservices.

That’s it!

Purchasing module

To start simple, in the next post will start implementing the purchasing module. For this module, the AA required the Spring Boot with Java. So, prepare your Eclipse|Intellij|Netbeans|VIM IDE.

To keep the database evolution easy and sweet, in the next post I’ll introduce the great Liquibase tool.

See ya!