Achieving Continuous Delivery with Docker for Java Enterprise applications Petyo Dimitrov | Musala Soft JSC 18-19 November, Sofia

Agenda • • • • • • • 2/38 A typical Enterprise Java landscape Continuous Delivery pipeline Identified problems What are Docker containers? Docker “ecosystem” Demo Tips & Tricks 18-19 November, Sofia

Dev landscape for Java EE applications 3/38 18-19 November, Sofia

Continuous Delivery pipeline 4/38 18-19 November, Sofia

potential issues 5/38 18-19 November, Sofia

inadequate packaging of application artifacts 6/38 18-19 November, Sofia

inconsistencies across environments 7/38 18-19 November, Sofia

high cost supporting multiple static environments 8/38 18-19 November, Sofia

lack of freedom experimenting with new languages, technologies and frameworks 9/38 18-19 November, Sofia

how can docker containers help? 10/38 wait…what… containers? 18-19 November, Sofia

getting sea sick here!!! 11/38 18-19 November, Sofia

sea-free analogy 12/38 18-19 November, Sofia

High level view of a container • it is like a lightweight Virtual Machine • it provides: • own process space • own network interface • running stuff as root 13/38 18-19 November, Sofia

Low level view of a container • container = “process in a box” • shares kernel with host  boots faster • processes run directly on the host • there is no device emulation • none or little CPU, memory, network and I/O overhead 14/38 18-19 November, Sofia

Virtual machines vs Containers 15/38 18-19 November, Sofia .

How does it work? – Isolation • isolation via namespaces • pid, mnt, net, uts, user, ipc • isolation via control groups • memory, cpu, blkio, devices 16/38 18-19 November, Sofia

How does it work? – Storage • union file system (aufs, overlayfs) • allows reusing common layers • reduces traffic and storage • allows tracking changes • copy-on-write pattern used for speed 17/38 18-19 November, Sofia

Developers Operations • care about apps • care about containers • put stuff in containers • work with containers • code & data • logging & monitoring • libraries • networking • applications • scaling 18/38 18-19 November, Sofia

docker “ecosystem” 19/38 18-19 November, Sofia

Client-Server model 20/38 18-19 November, Sofia

Docker engine • runs and commoditizes Linux containers • uses copy-on-write for quick provisioning • runs as daemon and has CLI • allows building and sharing images • functionality is exposed via REST API • defines standard format for containers 21/38 18-19 November, Sofia

Docker commands • ~40 commands • for working with: • images • containers • registry 22/38 18-19 November, Sofia

Dockerfile-s FROM jenkins:1.625.1 MAINTAINER Petyo Dimitrov ENV REFRESHED_AT 2015-10-24 RUN curl -L https://github.com/… > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose RUN mkdir /var/cache/jenkins RUN chown -R jenkins:jenkins /var/cache/jenkins docker build –t myjenkins .

Set Defaults ENV JAVA_OPTS=”-Xmx6144m” ENV JENKINS_OPTS=”—handlerCountMax=300 —webroot=/var/cache/jenkins/war”

COPY plugins.txt /plugins.txt RUN /usr/local/bin/plugins.sh /plugins.txt 23/38 18-19 November, Sofia

Docker Hub/Registry • collection of ready-made images • options: • public/private registry • local registry • REST API for access 24/38 18-19 November, Sofia

But how to build a stack of containers? 25/38 18-19 November, Sofia

Docker Compose • manages a collection of containers • fast, isolated development environments using Docker • define environment via YAML file • quick and easy to start docker-compose up –d 26/38 18-19 November, Sofia

YAML example 27/38 18-19 November, Sofia

How can I quickly provision a Docker host? 28/38 18-19 November, Sofia

Docker Machine • allows creating Docker hosts on local computer or in cloud providers • automatically creates host, installs Docker and configures the client • offers commands to start, stop, restart and inspect a host docker-machine create —driver virtualbox default 29/38 18-19 November, Sofia

Docker Summary • put my software in containers • run those containers anywhere • write recipes to automatically build containers 30/38 18-19 November, Sofia

Demonstration https://github.com/petyodimitrov/spring-music.git https://github.com/petyodimitrov/app-setup.git https://github.com/petyodimitrov/ci-setup.git 31/38 18-19 November, Sofia

Standard Java application build 2 1 32/38 18-19 November, Sofia

Adding docker images build 4 1 2 33/38 3 5 18-19 November, Sofia

Runtime view of containers 34/38 18-19 November, Sofia

Demonstration 35/38 18-19 November, Sofia

36/38 18-19 November, Sofia

Tips & Tricks • • • • • 37/38 single process per container security considerations use data containers for portability consider reducing image sizes etc… 18-19 November, Sofia

Thank you! petyo.dimitrov@gmail.com Petyo Dimitrov | Musala Soft JSC 18-19 November, Sofia