Download - JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Transcript
Page 1: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Johan Janssen, Info Support

Page 2: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Continuous Delivery

DockerDocker

Jenkins build pipeline

Questions

Page 3: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Automate everything

Software quality

Continuous improvement

Regular deployments

Anyone can deploy

Page 4: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

DevOps End users

Page 5: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 6: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Automate environment provisioning

Automate application deployment

Page 7: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 8: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 9: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 10: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 11: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 12: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 13: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Simple general commandsNo Domain Specific Language (DSL)Configuration with operating system commands

Disk space efficiencyMemory efficiencySpeedCompatibility (run anywhere)Isolation

Page 14: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 15: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Since March 2013Soon: 1.0 production ready releaseAround 400 contributorsAround 400 contributors1.2M+ container downloads

Page 16: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Docker on Ubuntu 14.04

apt-get install docker.io

docker.io run -i -t ubuntu:saucy/bin/bash

Page 17: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 18: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 19: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

FROM ubuntu:saucy

# Add oracle java 7 repository

RUN apt-get -y install software-properties-common

RUN add-apt-repository ppa:webupd8team/java

RUN apt-get update && apt-get -y upgradeRUN apt-get update && apt-get -y upgrade

# Accept the Oracle Java license

RUN echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true" | debconf-set-selections

# Install Oracle Java

RUN apt-get -y install oracle-java7-installer

ENV JAVA_HOME /usr/lib/jvm/java-7-oracle

Page 20: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

FROM GeneralBase

RUN apt-get install -y wget unzip

RUN wgethttp://dist.sonar.codehaus.org/sonarqube-http://dist.sonar.codehaus.org/sonarqube-4.2.zip

RUN unzip sonarqube-4.2.zip -d /opt

RUN rm sonarqube-4.2.zip

EXPOSE 9000

EXPOSE 9092

CMD ["/opt/sonarqube-4.2/bin/linux-x86-64/sonar.sh", "console", "/bin/bash"]

Page 21: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Create ‘Dockerfile’

Build the containers:Build the containers:docker.io build -t GeneralBase .docker.io build -t Sonar .

Start proces:docker.io run -p 9000:9000

–p 9092:9092 -d Sonar

Page 22: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

# docker.io ps –a

CONTAINER ID: ecbecf77461b

IMAGE: Sonar:latest

COMMAND: /opt/sonarqube-4.2/b COMMAND: /opt/sonarqube-4.2/b

CREATED: 32 minutes ago

STATUS: Up 32 minutes

PORTS: 0.0.0.0:9000->9000/tcp, 0.0.0.0:9092->9092/tcp

NAMES: sick_nobel

Page 23: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Start / stop / restartdocker.io [start / stop / restart] containerid

Show processes running in containerdocker.io top containerid

Page 24: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Create image from container

docker.io commit containeriddocker.io commit containeridusername/imagename

docker.io push username/imagename

Page 25: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

GeneralBaseGeneralBaseGeneralBaseGeneralBase

AppServerBaseAppServerBaseAppServerBaseAppServerBase JenkinsJenkinsJenkinsJenkins SonarSonarSonarSonar GitblitGitblitGitblitGitblit NexusNexusNexusNexus

Environment DEnvironment DEnvironment DEnvironment D

Environment TEnvironment TEnvironment TEnvironment T

Environment AEnvironment AEnvironment AEnvironment A

Environment PEnvironment PEnvironment PEnvironment P

JenkinsDataContainerJenkinsDataContainerJenkinsDataContainerJenkinsDataContainer

Page 26: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

DockerfileENV JENKINS_HOME /var/JenkinsData

Docker commandsDocker commandsdocker.io run -v /var/JenkinsData –name

JenkinsDataContainer ubuntu:saucy true

docker.io run -p 8080:8080 --volumes-from

JenkinsDataContainer -d Jenkins

Page 27: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

# docker.io images --tree└─ 179.9 MB Tags: ubuntu:saucy

└─253.6 MB└─741.8 MB Tags: GeneralBase:latest

└─763.6 MB Tags: AppServerBase:latest└─763.6 MB Tags: AppServerBase:latest├─763.6 MB Tags: EnvironmentP:latest├─763.6 MB Tags: EnvironmentA:latest├─763.6 MB Tags: EnvironmentT:latest└─763.6 MB Tags: EnvironmentD:latest

└─865.6 MB Tags: Nexus:latest└─808.3 MB Tags: Gitblit:latest└─901.5 MB Tags: Sonar:latest└─805.4 MB Tags: Jenkins:latest

Page 28: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 29: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 30: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 31: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Stop containersdocker.io stop $(docker.io ps -a -q)

Remove containersRemove containersdocker.io rm $(docker.io ps -a -q)

Remove imagesdocker.io rmi $(docker.io images -q)

Page 32: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

real 4m11.729sreal 4m11.729s

user 0m3.329s

sys 0m10.054s

Page 33: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 34: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Simple to useReally popular

Used in many organizationsRegular updatesRegular updatesBig community creating plugins etc.

Most developers already use it

Page 35: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 36: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 37: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 38: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Continuous delivery

Continuous deployment

Page 39: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 40: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

1

25

34

5

6

7

8

Page 41: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 42: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 43: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Execute job after several (parallel) jobs are finished.

FirstJobParallelJob1ParallelJob2

LastJob

Page 44: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 45: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen
Page 46: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Good looking joinComplex workflowEtceteraEtcetera

Advantage: Jenkins jobs are the basis and can be reused.Try to keep it simple!

Page 47: JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Docker – Johan Janssen

Build Flow PluginoDomain Specific LanguageoFeatures like retry, parallel, oFeatures like retry, parallel, guard/rescue (similar to try/finally)Multijob PluginDelivery Pipeline Plugin