'

Improve your Java Environment with Docker

Понравилась презентация – покажи это...





Слайд 0

Improve your Java development env with DOCKER Compose & Machine Copyright 2015 eXo Platform


Слайд 1

About Us ● Thomas Delhoménie ○ @tdelhomenie ● Software Engineer at eXo ● Maxime Gréau ○ @mgreau ● Software Engineer at eXo Copyright 2015 eXo Platform


Слайд 2

1. Docker Toolbox 2. Work on multiple technical stacks 3. Uses cases “In A Container” 3.1. Debug 3.2. Code & Deploy 3.3. Deploy from your IDE 3.4. Build & Run with Maven Docker Plugins 3.5. Integration Tests 4. Reproduce production bugs easily 5. Work with an architecture closest to production 6. Do all the things with Docker & co Copyright 2015 eXo Platform Agenda


Слайд 3

What’s the PROBLEM with my development environment? Copyright 2015 eXo Platform


Слайд 4

Problem 1: Dev environment setup time Welcome, it’s your first day, you just have to: ● Install Maven 3.2.3 ● Install JDK 1.7.0_80 ● Install Tomcat 7.0.63 ● Install MySQL 5.5, PostgreSQL 9.1 ● Read the installation doc… Copyright 2015 eXo Platform


Слайд 5

The BIG installation doc ! Copyright 2015 eXo Platform


Слайд 6

And after 1 hour....


Слайд 7

Problem 2: Works on my machine Copyright 2015 eXo Platform


Слайд 8

Problem 3: the matrix hell MySQL 5.1 My first app v1 X Mongo 3.0 X My first app v2 MySQL 5.5 My other app v1 Java 7 Java 8 X X X X ... Copyright 2015 eXo Platform X X


Слайд 9

Fix all those problems with 3 commands! Pre-requisites docker, machine & compose installed Then 1. Run git clone https://github.com/my-repo/my.git & cd my-project 2. Run docker-compose up 3. Open your browser Copyright 2015 eXo Platform


Слайд 10

Docker TOOLBOX For OSX and Windows Copyright 2015 eXo Platform


Слайд 11

Docker Toolbox includes... ● Docker Machine for running the docker-machine binary ● Docker Engine for running the docker binary ● Docker Compose for running the docker-compose binary ● Kitematic, the Docker GUI ● Oracle VM VirtualBox Copyright 2015 eXo Platform Only for OSX and Windows


Слайд 12

Create dev environment Mac & Windows > docker-machine create my-machine-name > eval $(docker-machine env my-machine-name) Linux Nothing special to do! Copyright 2015 eXo Platform


Слайд 13

TOURNAMENTS TENNIS APP Sample Application Copyright 2015 eXo Platform


Слайд 14

Tennis App - Screenshots batch-tennis-app.war ws-tennis-app.war Copyright 2015 eXo Platform


Слайд 15

Tennis App - Architecture - Java EE 7 batch-tennis-app.war Browser Batch API 1.0 CSV JPA 2.1 MySQL WildFly 8.2 ws-tennis-app.war JSON-P 1.0 WebSocket API 1.0 CDI 1.1 WildFly 8.2 Copyright 2015 eXo Platform


Слайд 16

As a Developer you want to Work on multiple technical stacks Copyright 2015 eXo Platform


Слайд 17

Multiple apps with docker compose batch-tennis-app.war Wordpress Apache WildFly 8.2 Maria DB 10.0 MySQL 5.7 Copyright 2015 eXo Platform


Слайд 18

DEMO 1 Application 1 Application 2 > git clone URL1 & cd app1 > mvn package > docker-compose up > git clone URL2 & cd app2 > docker-compose up open your browser ! open your browser ! Copyright 2015 eXo Platform


Слайд 19

Tennis App Batch - Dockerfile FROM jboss/wildfly:8.2.1.Final RUN mkdir -p /opt/jboss/wildfly/standalone/deployments/ROOT.war/ RUN touch /opt/jboss/wildfly/standalone/deployments/ROOT.war.dodeploy VOLUME ["/opt/jboss/wildfly/standalone/deployments/ROOT.war/"] ENV MYSQL_CONNECTOR_VERSION 5.1.34 RUN /opt/jboss/wildfly/bin/add-user.sh -up mgmt-users.properties admin Admin#70365 --silent # Install mysql driver RUN curl -L -o /opt/jboss/wildfly/standalone/deployments/mysql-connector-java.jar https://repo1. maven.org/maven2/mysql/mysql-connector-java/${MYSQL_CONNECTOR_VERSION}/mysqlconnector-java-${MYSQL_CONNECTOR_VERSION}.jar CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"] Copyright 2015 eXo Platform


Слайд 20

Tennis App Batch - docker-compose.yml batch_run: build: ./docker/dev/run/backend ports: - "7777:8080" volumes: - ./app/batch/target/batch:/opt/jboss/wildfly/standalone/deployments/ROOT.war/ links: - db dbdata: image: mysql:5.7 volumes: - /var/lib/mysql db: image: mysql:5.7 volumes_from: - dbdata environment: - MYSQL_ROOT_PASSWORD=tennistour - MYSQL_DATABASE=tennistour - MYSQL_USER=tennistour - MYSQL_PASSWORD=tennistour Copyright 2015 eXo Platform


Слайд 21

PHP Application - Dockerfile (Wordpress) FROM php:5.6-apache RUN a2enmod rewrite # install the PHP extensions we need RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-install gd RUN docker-php-ext-install mysqli VOLUME /var/www/html ENV WORDPRESS_VERSION 4.3.1 ENV WORDPRESS_SHA1 b2e5652a6d2333cabe7b37459362a3e5b8b66221 # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress RUN curl -o wordpress.tar.gz -SL https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz \ && echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c - \ && tar -xzf wordpress.tar.gz -C /usr/src/ \ && rm wordpress.tar.gz \ && chown -R www-data:www-data /usr/src/wordpress COPY docker-entrypoint.sh /entrypoint.sh # grr, ENTRYPOINT resets CMD now ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] Copyright 2015 eXo Platform


Слайд 22

PHP Application - docker-compose.yml wordpress: image: wordpress links: - db:mysql ports: - 8080:80 db: image: mariadb environment: MYSQL_ROOT_PASSWORD: example Copyright 2015 eXo Platform


Слайд 23

Others use cases eXo use case : multi databases support (matrix compatibility pb) MySQL 5.5 MySQL 5.6 PostgreSQL 9.3 PostgreSQL 9.4 Copyright 2015 eXo Platform Oracle 11gR2


Слайд 24

Others use cases Migration between 2 versions of the database my-app my-app MySQL 5.5 MySQL 5.7 Copyright 2015 eXo Platform


Слайд 25

USE CASES “In a Container” Copyright 2015 eXo Platform


Слайд 26

As a Developer you want to Debug Java app in a container Copyright 2015 eXo Platform


Слайд 27

How to debug in a container ? Remote debug batch-tennis-app.war WildFly 8.2 MySQL 5.7 Copyright 2015 eXo Platform


Слайд 28

DEMO 2 Copyright 2015 eXo Platform


Слайд 29

As a Developer you want to Code and deploy Copyright 2015 eXo Platform


Слайд 30

How to deploy a new war ? ● Update your code in your favorite IDE ● Build with maven ● Open your browser ! Copyright 2015 eXo Platform


Слайд 31

DEMO 3 Copyright 2015 eXo Platform


Слайд 32

As a Developer you want to Use your IDE to deploy in a container Copyright 2015 eXo Platform


Слайд 33

IDE starts to support Docker container technology ● Eclipse Mars (2015) ● Netbeans ● IntelliJ IDEA v14.1 Copyright 2015 eXo Platform


Слайд 34

As a Developer you want to Build & Run with Maven Docker plugins Copyright 2015 eXo Platform


Слайд 35

Docker Maven plugins mvn docker:start mvn tomcat:run https://github.com/rhuss/docker-maven-plugin Copyright 2015 eXo Platform


Слайд 36

As a Developer you want to Execute Integration Tests in containers Copyright 2015 eXo Platform


Слайд 37

Arquillian - Intro ● Automated tests without mocks ● Compatible JUnit/TestNG ● Application Server agnostic ● Embedded/Managed/Client modes Copyright 2015 eXo Platform


Слайд 38

Arquillian Cube http://arquillian.org/modules/cube-extension/ Shameless auto-promotion : http://mgreau.com/posts/2015/03/03/dockerasciidoctorj-wildfly-arquillian.html Copyright 2015 eXo Platform


Слайд 39

As a Developer you want to Easily reproduce production bugs Copyright 2015 eXo Platform


Слайд 40

Test with the production version of the “old” stack my-app v1 > git checkout v1 > “build” > docker-compose up my-app v2 MySQL 5.5 5.5 5.7 MySQL 5.7 Prod stack New dev stack Copyright 2015 eXo Platform


Слайд 41

As a Developer you want to Work with an architecture close to production Copyright 2015 eXo Platform


Слайд 42

Angular / Java EE 7 Application CSV Apache HTTPD batch-tennis-app.war MySQL WildFly 8.2 ws-tennis-app.war WildFly 8.2 UI Angular Load Balancer ws-tennis-app.war WildFly 8.2 ws-tennis-app.war WildFly 8.2 Copyright 2015 eXo Platform Cache Redis


Слайд 43

DEMO 4 Copyright 2015 eXo Platform


Слайд 44

DO ALL THE THINGS WITH DOCKER Copyright 2015 eXo Platform


Слайд 45

Build your projects with docker You will only need docker tools on your laptop! Copyright 2015 eXo Platform


Слайд 46

DEMO 5 Copyright 2015 eXo Platform


Слайд 47

Docker TOOLS Copyright 2015 eXo Platform


Слайд 48

GUI for Docker ● Kitematic ● DockerUI Copyright 2015 eXo Platform


Слайд 49

Docker BEST PRACTICES Copyright 2015 eXo Platform


Слайд 50

Some best practices for development ● Use Docker Machine to organize your images and limit resources usage (CPU, memory, …) ● Use volume containers to keep your data safe (schema) ● Useful docker commands: ○ stopped docker containers : docker stop $(docker ps -q) ○ remove dangling docker images: ■ ○ docker rmi $(docker images -q -f "dangling=true") and more: https://github.com/javaee-samples/dockerjava/blob/master/chapters/docker-commands.adoc Copyright 2015 eXo Platform


Слайд 51

Docker doesn’t invent the container technology, BUT make it possible to use it easily on your laptop! Copyright 2015 eXo Platform


Слайд 52

Improve your Java development env with Docker Compose & Machine Thanks @tdelhomenie @mgreau Code: http://github.com/mgreau/docker4dev-tennistour-app


Слайд 53


×

HTML:





Ссылка: