Greach 2016 dockerize your grails

31
Dockerize your Grails! Iván López - @ilopmar

Transcript of Greach 2016 dockerize your grails

Dockerize your Grails!

Iván López - @ilopmar

➢ Iván López @ilopmar

➢ Groovy & Grails developer

➢ @madridgug coordinator

➢ @greachconf organizerhttp://greachconf.com

➢ Speaker: SpringOne 2GX, GR8Conf, GGX, Codemotion,GeeCon, jDays, Spring IO, Greach, RigaDevDay, ConFess,...

About me...

1.Problems

If there wasanother way...

Please, kill me toend my pain!

2.Docker

Basics about Docker

➢ Portable runtime for the app

➢ Run each app in its own isolated container

➢ Eliminate concerns about compatibility on different platforms

➢ Like a VM without the overhead of a VM

➢ Lightweight than a VM

Hypervisor

Host OS

Server

VM

AppA

GuestOS

Bins/Libs

AppA'

GuestOS

Bins/Libs

AppB

GuestOS

Bins/Libs

Do

cker

Host OS

Server

Bins/Libs

Container

Bins/Libs

VM vs Docker

App A

App A'

App B

App B'

App B'

App B'

$ docker run --rm ubuntu echo “Hello Greach!”

Hello Greach!

Basics

$ docker run --rm java:9 java -versionopenjdk version "9-internal"

OpenJDK Runtime Environment (build 9-internal+0-2016-01-26-172948.buildd.src)

OpenJDK 64-Bit Server VM (build 9-internal+0-2016-01-26-172948.buildd.src, mixed mode)

$ alias java="docker run --rm java:9 java"

$ java -version

Basics

Create image

FROM nginx:1.9.12

COPY index.html /usr/share/nginx/html/

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

Dockerfile

<h1>Hello Greach!</h1>

index.html

$ docker build -t greach .Sending build context to Docker daemon 3.072 kB

Step 1 : FROM nginx:1.9.12

---> 6dde4f9ae735

Step 2 : COPY index.html /usr/share/nginx/html/

---> c1c0f4eeffe4

Removing intermediate container 08fb8441e6be

Step 3 : EXPOSE 80

---> Running in 4d6151c06c9b

---> e07151354dc9

Removing intermediate container 4d6151c06c9b

Step 4 : CMD nginx -g daemon off;

---> Running in 8edd425ce757

---> ef945069377f

Removing intermediate container 8edd425ce757

Successfully built ef945069377f

Create image

$ docker run --rm -p 1234:80 greach

Running our image

$ docker run -it -p 1234:80 greach

Running our image

3.Grails & Docker

What if a new team member...

➢ Install Docker

➢ Clone the repo

➢ Run script

➢ Profit!

Our application

Producer Consumer

Debian 8 Java 8 RabbitMQ 3.6 Postgres 9.4Grails 3.1.4

Two options

The easy way

One image to rule them all

The easy way

➢ Everything installed on the same container

➢ More than one process per container (!!)

➢ Easy to maintain and use

➢ Focused only on development

Two options

The flexible way

Orchestration to the rescue

The flexible way

➢ Each application in different container

➢ Only one process per container

➢ More complicated to maintain

➢ More flexible and ready for other environments

4.Demo

5.Summary

Summary

Easy to start beingproductive

Developers have the exact environment

Control the exact version of everything

Orchestration is more complicated

But it's more powerful

Everyone is happy

Thank you!Questions?

http://bit.ly/greach-docker

@ilopmar

[email protected]

https://github.com/ilopmar

Iván López