g3 summit 2016 - dockerize your grails!

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

Upload: ivan-lopez

Post on 08-Jan-2017

4.222 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: G3 Summit 2016 - Dockerize your Grails!

G3 Summit

Dockerize your Grails!

Iván López - @ilopmar

Page 2: G3 Summit 2016 - Dockerize your Grails!

➢ Iván López - @ilopmar

➢ Groovy & Grails developer

Member of Grails team at OCI

➢ @MadridGUG coordinator

http://www.madridgug.com

➢ Greach organizer (@greachconf)

http://greachconf.com

➢ Speaker: SpringOne 2GX, GR8Conf, Codemotion, GeeCon, Spring IO, Greach, JavaCro, RigaDevDay,...

About me...

Page 3: G3 Summit 2016 - Dockerize your Grails!

1.Problems

Page 4: G3 Summit 2016 - Dockerize your Grails!
Page 5: G3 Summit 2016 - Dockerize your Grails!
Page 6: G3 Summit 2016 - Dockerize your Grails!
Page 7: G3 Summit 2016 - Dockerize your Grails!
Page 8: G3 Summit 2016 - Dockerize your Grails!
Page 9: G3 Summit 2016 - Dockerize your Grails!
Page 10: G3 Summit 2016 - Dockerize your Grails!

If there wasanother way...

Please, kill me toend my pain!

Page 11: G3 Summit 2016 - Dockerize your Grails!
Page 12: G3 Summit 2016 - Dockerize your Grails!

2.Docker

Page 13: G3 Summit 2016 - Dockerize your Grails!

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

Page 14: G3 Summit 2016 - Dockerize your Grails!

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'

Page 15: G3 Summit 2016 - Dockerize your Grails!

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

Basics

Page 16: G3 Summit 2016 - Dockerize your Grails!

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

OpenJDK Runtime Environment (build 9-Debian+0-9b140-1)

OpenJDK 64-Bit Server VM (build 9-Debian+0-9b140-1, mixed mode)

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

$ java -version

Basics

Page 17: G3 Summit 2016 - Dockerize your Grails!

Create image

FROM nginx:1.11.5

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

EXPOSE 80

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

Dockerfile

<h1>Hello G3Summit!</h1>

index.html

Page 18: G3 Summit 2016 - Dockerize your Grails!

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

Step 1 : FROM nginx:1.11.5

---> 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

Page 19: G3 Summit 2016 - Dockerize your Grails!

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

Running our image

Page 20: G3 Summit 2016 - Dockerize your Grails!

$ docker run -it -p 1234:80 greach

Running our image

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

Page 21: G3 Summit 2016 - Dockerize your Grails!

3.Grails & Docker

Page 22: G3 Summit 2016 - Dockerize your Grails!

Let’s fix the problems!

➢ Install Docker

➢ Clone the repo

➢ Run script

➢ Profit!

Page 23: G3 Summit 2016 - Dockerize your Grails!

Our application

Producer Consumer

Debian 8 Java 8 RabbitMQ 3.6 Postgres 9.4Grails 3.2.3

Page 24: G3 Summit 2016 - Dockerize your Grails!

Two options

The easy way

One image to rule them all

Page 25: G3 Summit 2016 - Dockerize your Grails!

The easy way

➢ Everything installed on the same container

➢ More than one process per container (!!)

➢ Easy to maintain and use

➢ Focused only on development

Page 26: G3 Summit 2016 - Dockerize your Grails!

Two options

The flexible way

Orchestration to the rescue

Page 27: G3 Summit 2016 - Dockerize your Grails!

The flexible way

➢ Each application in different container

➢ Only one process per container

➢ More complicated to maintain

➢ More flexible and ready for other environments

Page 28: G3 Summit 2016 - Dockerize your Grails!

4.Demo

Page 29: G3 Summit 2016 - Dockerize your Grails!

5.Summary

Page 30: G3 Summit 2016 - Dockerize your Grails!

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

Page 31: G3 Summit 2016 - Dockerize your Grails!

Thank you!Questions?

http://bit.ly/g3summit-docker

@ilopmar

[email protected]

https://github.com/ilopmar

Iván López