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

Greach 2016 dockerize your grails

Apr 15, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Greach 2016   dockerize your grails

Dockerize your Grails!

Iván López - @ilopmar

Page 2: Greach 2016   dockerize your grails

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

Page 3: Greach 2016   dockerize your grails

1.Problems

Page 4: Greach 2016   dockerize your grails
Page 5: Greach 2016   dockerize your grails
Page 6: Greach 2016   dockerize your grails
Page 7: Greach 2016   dockerize your grails
Page 8: Greach 2016   dockerize your grails
Page 9: Greach 2016   dockerize your grails
Page 10: Greach 2016   dockerize your grails

If there wasanother way...

Please, kill me toend my pain!

Page 11: Greach 2016   dockerize your grails
Page 12: Greach 2016   dockerize your grails

2.Docker

Page 13: Greach 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: Greach 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: Greach 2016   dockerize your grails

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

Hello Greach!

Basics

Page 16: Greach 2016   dockerize your grails

$ 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

Page 17: Greach 2016   dockerize your grails

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

Page 18: Greach 2016   dockerize your grails

$ 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

Page 19: Greach 2016   dockerize your grails

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

Running our image

Page 20: Greach 2016   dockerize your grails

$ docker run -it -p 1234:80 greach

Running our image

Page 21: Greach 2016   dockerize your grails

3.Grails & Docker

Page 22: Greach 2016   dockerize your grails

What if a new team member...

➢ Install Docker

➢ Clone the repo

➢ Run script

➢ Profit!

Page 23: Greach 2016   dockerize your grails

Our application

Producer Consumer

Debian 8 Java 8 RabbitMQ 3.6 Postgres 9.4Grails 3.1.4

Page 24: Greach 2016   dockerize your grails

Two options

The easy way

One image to rule them all

Page 25: Greach 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: Greach 2016   dockerize your grails

Two options

The flexible way

Orchestration to the rescue

Page 27: Greach 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: Greach 2016   dockerize your grails

4.Demo

Page 29: Greach 2016   dockerize your grails

5.Summary

Page 30: Greach 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: Greach 2016   dockerize your grails

Thank you!Questions?

http://bit.ly/greach-docker

@ilopmar

[email protected]

https://github.com/ilopmar

Iván López