SlideShare a Scribd company logo
1
Transitioning to Java
MicroServices on Docker
Lana Kalashnyk
W Consulting Group
Welcome to Houston TechFest
• Please turn off all electronic devices or set them to vibrate.
• If you must take a phone call, please do so in the lobby so as not
to disturb others.
• Thanks to our Diamond Sponsors:
Thank you for being a part of the
9th
Annual Houston TechFest!
3
Transitioning to Java Microservices
• Let’s talk about …
• Microservices :
– Microservices … what makes them different ?
– Microservice Architectures
• What is Docker?
– Containers are in .
– How to use Docker for microservices.
• Business Application: Outdated Web Services.
• Demo of a Java Microservice running in a Docker container,
providing status updates on a Bitcoin Node block height.
4
About Me
Lana Kalashnyk
•BAAS Computer Science minor Business Administration
•AS in Computer Science emphasis on Networking
•Cisco CCNA I-IV, Red Hat JAX-RS, NetSuite, CODE
WPF, Oracle Java training
•Houston Java User Group, Houston .Net User Group,
Texas DevOps User Group, PuppetConf Test Pilot
•Fan of back end engineering, cloud technologies,
innovation and running.
www.wcgp.co
Twitter: lana_vk
5
• When did Microservices became
a thing?
• Not a new Idea, but a relatively
new trend in Software
Architectures for smaller
companies.
• Mentioned in 2011 Yegge Memo
to Google about the way
Amazon largely runs their
company as microservices
communicating exclusively over
APIs.
https://plus.google.com/
+RipRowan/posts/eVeouesvaVX
The Rise of The Microservices
6
Company culture matters
“Any organization that designs a system (defined broadly)
will produce a design whose structure is a copy of the
organization's communication structure.” – Melvin Conway,
1967
7
What is a Microservice ?
Microservices is a software architecture style in which
complex applications are composed of small, independent
processes.
– These processes communicate with each other using language-
agnostic APIs.
– These services are small, highly decoupled and focus on doing a
small task.
– Facilitate a modular approach to system-building.
– The service is autonomous; it is full-stack and has control of all
the components – UI, middleware, persistence, transaction.
•“A perfect JavaEE microservice is single ECB component
within a WAR deployed on a single server”
8
Benefits of using Microservices
A Well written Microservice operates on a single
resource.
•Allows to focus on building a product rather than a project. (each
service is developed independently, not a refactor of a monolith)
•Independently deployable.
•Smart endpoints.
•RESTFUL protocols or Message queues can be used for non-blocking
communication.
•Doesn’t have to be all in one technology
•Infrastructure Automation : making releases boring .
•Fault isolation : Helps with fixing the issue, rather than deploying a
patch .
9
Pitfalls of using Microservices
• Creating so-called Nanoservices . Services that are too
granular, their maintenance and implementation are
counterproductive.
• Lack of Tooling. Transitioning to a microservice
architecture implies investment into management and
monitoring tools. Failure to do so will surely result in a
poor system.
• Change Management, Transactions and Data Integrity
can be tricky
10
Microservice Architecture Patterns
• Aggregate : An aggregator invokes multiple
microservices to achieve desired functionality.
11
Microservice Architecture Patterns
• Chained: A single microservice produces a single
consolidated response. Service A invokes Service B… etc
12
Microservice Architecture Patterns
• Shared data: Microservices access the same
database.
13
What are containers ?
• Containers are a solution to the problem of how to get software to
run reliably when moved from one computing environment to
another.
• Put simply, a container consists of an entire runtime environment:
an application, plus all its dependencies, libraries and other binaries,
and configuration files needed to run it, bundled into one package.
“By containerizing the application
platform and its dependencies,
differences in OS distributions
and underlying infrastructure
are abstracted away.” –Paul Rubens CIO
14
Why do we need them?
• Immutable Servers – BIG WIN
– Immutable containers mean that they will never be changed. A new version
of an application is deployed in a new container
• No More Magical Servers.
– You deploy in the environment you build the product for… all the time.
• Isolation. Applications are isolated by the container
boundaries.
• Smarter use of resources when compared to separate
VMs.
• Continuous Integration and Delivery .
15
What is Docker?
Docker is an open platform for building, shipping and running distributed
applications. It gives programmers, development teams and operations engineers
the common toolbox they need to take advantage of the distributed and networked
nature of modern applications.
Docker consists of:
•The Docker Engine - container virtualization technology combined with a work flow
for building and containerizing applications.
•Docker Hub - SaaS service for sharing and managing your application stacks.
CoreOS rkt is the only other major player in the field.
16
Docker Architecture
17
Deploying Microservices on Docker
• Microservice and any necessary software is
“baked” into a Docker Image.
• The Image is created based on a Docker file. All
necessary set up is specified here.
• Docker Images are stored in Docker Registry
• Multi-container applications can be defined using
Docker compose.
• Containers can be deployed as a Cluster using
Docker SWARM.
18
Transition from .Net Web Services on IIS
• In a recent project we replaced outdated .Net
Web Services running on an IIS Service with Java
Microservice deployed on Docker in a Wildfly AS .
– Good candidate due to few dependencies.
– Already separated by product in separate web services
– Needed to drastically cut costs
– Low risk project since doesn’t provide critical data
writes
– Other applications in the eco system were already
Java based
19
Usage Example: Previous Architecture
20
Usage Example: New Architecture
21
Work in Progress
• Committing to a microservice architecture beyond
a small project is a much bigger undertaking.
• Define architecture patterns for cross technology
interactions
• Define scaling mechanisms
• Define state monitoring
• Or deploy on AWS or Google to leverage their
pre-built tools
22
And now a working Example !
• The following solution imitates the previous
architecture. It consists of :
– Virtual Machine : Complex Web Application ( Bitcoin
Node)
– Docker Container : Java Microservice polling the
Bitcoin Node
– Simple ReactJS Web Page displaying the results.
23
Pre requisites
• Install a Bitcoin Node
– I used AWS EC2 t2.medium instance w/ 48 GiB
volume.
– Configure the Security group to allow traffic to our
node from other bitcoin nodes and our application.
24
Configure the Bitcoin Node
• Install the bitcoin node software on your provisioned server.
• Configure the node to accept JSON-RPC requests from our IP only.
– sudo vi .bitcoin/bitcoin.conf
• Start the bitcoin daemon. Now you can manage it using bitcoin-cli commands
– sudo bitcoind –daemon
– sudo bitcoin-cli getinfo
25
Writing a Java Microservice
• Install Maven, Git, NetBeans (or an IDE of your
choice)
• Only work on a single resource
– Here a Bitcoin Node
• Make the end points RESTFUL (PUT, POST, GET)
• Use JSON to package objects.
• Report Errors
• Log
26
Writing a Java Microservice
27
Writing a Java Microservice
28
Wildfy Swarm
• Add Wildfly Swarm Dependency & Plugin
to package the service into a container
in your pom file
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-jaxrs-
weld</artifactId>
<version>1.0.0.Alpha5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.2</version>
</dependency>
…
<!-- *** Swarm Plugin *** -->
<!-- Specify the main class in your app -->
<!-- Executution phase and goal -->
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-
plugin</artifactId>
<configuration>
<mainClass>com.mius.javajaxrsmicroservic
e.JaxRSServriceSwarmMain</mainClass>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
29
Could stop here..
• Build the Service and package it into a Swarm
Container
– mvn clean package
• Jar file is fully executable…
• Execute using
– “java –jar JavaMSDocker-swarm.jar”
• but then we wouldn’t get to talk about Docker.
30
Install Docker
• https://docs.docker.com/compose/install/
• Depending on your OS you can either run Docker
natively or in a VirtualBox
• Docker Toolbox installs Docker Machine and other
tools like Kitematic.
31
Create a Docker File
• Create a file name “Dockerfile”
– Specify the base image
• FROM java:openjdk-8-jdk
– Copy over your files into the container
• ADD target/JavaMSDocker-swarm.jar /opt/JavaMSDocker-
swarm.jar
– Open port 8080 for our Service
• EXPOSE 8080
– Configure the container to run as an executable
• ENTRYPOINT ["java", "-jar", "/opt/JavaMSDocker-
swarm.jar"]
32
Docker Compose
• For Development use. Optional.
• Define all services to be ran together in a .yml file
• Create a file name “docker-compose.yml”
wildflyswarm: // define service name
build: . // path to the Dockerfile
ports:
- "8080:8080" // ports to expose HOST:CONTAINER
33
Create your Docker Image
• Run the following commands :
docker-compose build
docker run –p 8080:8080 javamsdocker_wildflyswarm
Or
docker-compose up
34
The service is live !
35
React Page to display the data
• For simplicity uses simple jquery to GET the
bitcoin node status from the java microservice
• Uses virtual DOM
• JSX transforms in browser
36
Final Page
37
References
https://en.wikipedia.org/wiki/Microservices
http://blog.arungupta.me/microservices-monoliths-noops/
https://www.voxxed.com/blog/2015/04/coupling-versus-autonomy-in-microservices/
http://www.javacodegeeks.com/2015/04/microservice-design-patterns.html
http://www.cio.com/article/2924995/enterprise-software/what-are-containers-and-why-do-you-need-them.html
https://docs.docker.com/introduction/understanding-docker/
http://wildfly.org/swarm/
http://tutorialzine.com/2014/07/5-practical-examples-for-learning-facebooks-react-framework/
http://blog.arungupta.me/deploy-javaee-docker-swarm-cluster/
https://bitcoin.org/en/full-node#ubuntu-1410
38
Pull this
GitHub Repo for the Bitcoin Monitor Demo
https://github.com/lana-
vk/JavaMicroServiceDocker
39
Thank You !
Lana Kalashnyk
W Consulting Group
wcgp.co
Twitter : @lana_vk
Please Leave Feedback During Q&A
If you leave session
feedback and provide
contact information in
the survey, you will be
qualified for a prize
Scan the QR Code to
the right or go to
http://bit.ly/1K1Hvi5
Thanks to all our Sponsors!

More Related Content

PDF
Java Microservices HJUG
PDF
Alibaba Cloud Conference 2016 - Docker Open Source
PDF
VMware@Night: Container & Virtualisierung
PPTX
Docker for the enterprise
PDF
Docker in pratice -chenyifei
PPTX
Executive Briefing: The Why, What, and Where of Containers
PDF
Docker Birthday #3 Slides - Overview
PDF
Alibaba Cloud Conference 2016 - Docker Enterprise
Java Microservices HJUG
Alibaba Cloud Conference 2016 - Docker Open Source
VMware@Night: Container & Virtualisierung
Docker for the enterprise
Docker in pratice -chenyifei
Executive Briefing: The Why, What, and Where of Containers
Docker Birthday #3 Slides - Overview
Alibaba Cloud Conference 2016 - Docker Enterprise

What's hot (20)

PPTX
Microservices architecture overview v2
PDF
QCon SF 2017 - Microservices: Service-Oriented Development
PDF
Getting Started with Docker - Nick Stinemates
PPTX
Docker EE 2.0 Choice, Security & Agility
PPTX
2015 03-11_todd-fritz_devnexus_2015
PPTX
microXchg 2018: "What is a Service Mesh? Do I Need One When Developing 'Cloud...
PDF
Microservices architecture overview v3
PDF
Containers, microservices and serverless for realists
PDF
JEE 8, A Big Overview
PDF
Cloud Native Patterns with Bluemix Developer Console
PDF
Journey to the devops automation with docker kubernetes and openshift
PDF
DevOps Indonesia #5 - The Future of Containers
PDF
Cloud Foundry OpenTour Kiev Keynote
PDF
Containers, OCI, CNCF, Magnum, Kuryr, and You!
PPTX
Jenkins 1
PPTX
PDF
Azure meetup cloud native concepts - may 28th 2018
PPTX
Microservices and docker
PDF
OpenShift for Java EE Developers
PDF
DevOps Days Boston 2017: Real-world Kubernetes for DevOps
Microservices architecture overview v2
QCon SF 2017 - Microservices: Service-Oriented Development
Getting Started with Docker - Nick Stinemates
Docker EE 2.0 Choice, Security & Agility
2015 03-11_todd-fritz_devnexus_2015
microXchg 2018: "What is a Service Mesh? Do I Need One When Developing 'Cloud...
Microservices architecture overview v3
Containers, microservices and serverless for realists
JEE 8, A Big Overview
Cloud Native Patterns with Bluemix Developer Console
Journey to the devops automation with docker kubernetes and openshift
DevOps Indonesia #5 - The Future of Containers
Cloud Foundry OpenTour Kiev Keynote
Containers, OCI, CNCF, Magnum, Kuryr, and You!
Jenkins 1
Azure meetup cloud native concepts - may 28th 2018
Microservices and docker
OpenShift for Java EE Developers
DevOps Days Boston 2017: Real-world Kubernetes for DevOps
Ad

Viewers also liked (20)

PDF
How to Build Cloud-based Microservice Environments with Docker and VoltDB
PPTX
Service Orchestrierung mit Apache Mesos
PDF
MicroService and MicroContainer with Apache Camel
PDF
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
PDF
Dockerize node.js application
PDF
Import golang; struct microservice - Codemotion Rome 2015
PDF
Full lifecycle of a microservice
PDF
Microservices architecture examples
PPTX
Write microservice in golang
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
PDF
Deploying Spring Boot applications with Docker (east bay cloud meetup dec 2014)
PDF
Service discovery in a microservice architecture using consul
PDF
Microservice Architecture on AWS using AWS Lambda and Docker Containers
PDF
DockerCon SF 2015: Faster, Cheaper, Safer
PDF
[D2 COMMUNITY] Open Container Seoul Meetup - 마이크로 서비스 아키텍쳐와 Docker kubernetes
PDF
Containers, Docker, and Microservices: the Terrific Trio
PDF
DockerCon SF 2015: Enabling Microservices @Orbitz
PPTX
Docker and Microservice
PDF
Microservice Composition with Docker and Panamax
PDF
Architecture microservices avec docker
How to Build Cloud-based Microservice Environments with Docker and VoltDB
Service Orchestrierung mit Apache Mesos
MicroService and MicroContainer with Apache Camel
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Dockerize node.js application
Import golang; struct microservice - Codemotion Rome 2015
Full lifecycle of a microservice
Microservices architecture examples
Write microservice in golang
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Deploying Spring Boot applications with Docker (east bay cloud meetup dec 2014)
Service discovery in a microservice architecture using consul
Microservice Architecture on AWS using AWS Lambda and Docker Containers
DockerCon SF 2015: Faster, Cheaper, Safer
[D2 COMMUNITY] Open Container Seoul Meetup - 마이크로 서비스 아키텍쳐와 Docker kubernetes
Containers, Docker, and Microservices: the Terrific Trio
DockerCon SF 2015: Enabling Microservices @Orbitz
Docker and Microservice
Microservice Composition with Docker and Panamax
Architecture microservices avec docker
Ad

Similar to TransitioningToMicroServonDocker_MS (20)

PDF
Microservices for java architects it-symposium-2015-09-15
PDF
Microservices: How loose is loosely coupled?
PDF
Microservices Interview Questions and Answers PDF By ScholarHat
PDF
Building Microservices Software practics
PDF
Refactor your Java EE application using Microservices and Containers - Arun G...
PPTX
Understanding Microservices
PDF
Integration in the Cloud, by Rob Davies
PDF
20141210 - Microservice Container
PPTX
Microservices and Best Practices
PPTX
Microservices approach for Websphere commerce
PPTX
Microservices and containers for the unitiated
PDF
The Need of Cloud-Native Application
PPSX
Microservices Architecture, Monolith Migration Patterns
PDF
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
PPTX
Kubernetes solutions
PDF
Microservices on a budget meetup
PDF
Architecting for Scale
PPTX
Docker & aPaaS: Enterprise Innovation and Trends for 2015
PPTX
Net core microservice development made easy with azure dev spaces
PDF
Developing Enterprise Applications for the Cloud, from Monolith to Microservice
Microservices for java architects it-symposium-2015-09-15
Microservices: How loose is loosely coupled?
Microservices Interview Questions and Answers PDF By ScholarHat
Building Microservices Software practics
Refactor your Java EE application using Microservices and Containers - Arun G...
Understanding Microservices
Integration in the Cloud, by Rob Davies
20141210 - Microservice Container
Microservices and Best Practices
Microservices approach for Websphere commerce
Microservices and containers for the unitiated
The Need of Cloud-Native Application
Microservices Architecture, Monolith Migration Patterns
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
Kubernetes solutions
Microservices on a budget meetup
Architecting for Scale
Docker & aPaaS: Enterprise Innovation and Trends for 2015
Net core microservice development made easy with azure dev spaces
Developing Enterprise Applications for the Cloud, from Monolith to Microservice

TransitioningToMicroServonDocker_MS

  • 1. 1 Transitioning to Java MicroServices on Docker Lana Kalashnyk W Consulting Group
  • 2. Welcome to Houston TechFest • Please turn off all electronic devices or set them to vibrate. • If you must take a phone call, please do so in the lobby so as not to disturb others. • Thanks to our Diamond Sponsors: Thank you for being a part of the 9th Annual Houston TechFest!
  • 3. 3 Transitioning to Java Microservices • Let’s talk about … • Microservices : – Microservices … what makes them different ? – Microservice Architectures • What is Docker? – Containers are in . – How to use Docker for microservices. • Business Application: Outdated Web Services. • Demo of a Java Microservice running in a Docker container, providing status updates on a Bitcoin Node block height.
  • 4. 4 About Me Lana Kalashnyk •BAAS Computer Science minor Business Administration •AS in Computer Science emphasis on Networking •Cisco CCNA I-IV, Red Hat JAX-RS, NetSuite, CODE WPF, Oracle Java training •Houston Java User Group, Houston .Net User Group, Texas DevOps User Group, PuppetConf Test Pilot •Fan of back end engineering, cloud technologies, innovation and running. www.wcgp.co Twitter: lana_vk
  • 5. 5 • When did Microservices became a thing? • Not a new Idea, but a relatively new trend in Software Architectures for smaller companies. • Mentioned in 2011 Yegge Memo to Google about the way Amazon largely runs their company as microservices communicating exclusively over APIs. https://plus.google.com/ +RipRowan/posts/eVeouesvaVX The Rise of The Microservices
  • 6. 6 Company culture matters “Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.” – Melvin Conway, 1967
  • 7. 7 What is a Microservice ? Microservices is a software architecture style in which complex applications are composed of small, independent processes. – These processes communicate with each other using language- agnostic APIs. – These services are small, highly decoupled and focus on doing a small task. – Facilitate a modular approach to system-building. – The service is autonomous; it is full-stack and has control of all the components – UI, middleware, persistence, transaction. •“A perfect JavaEE microservice is single ECB component within a WAR deployed on a single server”
  • 8. 8 Benefits of using Microservices A Well written Microservice operates on a single resource. •Allows to focus on building a product rather than a project. (each service is developed independently, not a refactor of a monolith) •Independently deployable. •Smart endpoints. •RESTFUL protocols or Message queues can be used for non-blocking communication. •Doesn’t have to be all in one technology •Infrastructure Automation : making releases boring . •Fault isolation : Helps with fixing the issue, rather than deploying a patch .
  • 9. 9 Pitfalls of using Microservices • Creating so-called Nanoservices . Services that are too granular, their maintenance and implementation are counterproductive. • Lack of Tooling. Transitioning to a microservice architecture implies investment into management and monitoring tools. Failure to do so will surely result in a poor system. • Change Management, Transactions and Data Integrity can be tricky
  • 10. 10 Microservice Architecture Patterns • Aggregate : An aggregator invokes multiple microservices to achieve desired functionality.
  • 11. 11 Microservice Architecture Patterns • Chained: A single microservice produces a single consolidated response. Service A invokes Service B… etc
  • 12. 12 Microservice Architecture Patterns • Shared data: Microservices access the same database.
  • 13. 13 What are containers ? • Containers are a solution to the problem of how to get software to run reliably when moved from one computing environment to another. • Put simply, a container consists of an entire runtime environment: an application, plus all its dependencies, libraries and other binaries, and configuration files needed to run it, bundled into one package. “By containerizing the application platform and its dependencies, differences in OS distributions and underlying infrastructure are abstracted away.” –Paul Rubens CIO
  • 14. 14 Why do we need them? • Immutable Servers – BIG WIN – Immutable containers mean that they will never be changed. A new version of an application is deployed in a new container • No More Magical Servers. – You deploy in the environment you build the product for… all the time. • Isolation. Applications are isolated by the container boundaries. • Smarter use of resources when compared to separate VMs. • Continuous Integration and Delivery .
  • 15. 15 What is Docker? Docker is an open platform for building, shipping and running distributed applications. It gives programmers, development teams and operations engineers the common toolbox they need to take advantage of the distributed and networked nature of modern applications. Docker consists of: •The Docker Engine - container virtualization technology combined with a work flow for building and containerizing applications. •Docker Hub - SaaS service for sharing and managing your application stacks. CoreOS rkt is the only other major player in the field.
  • 17. 17 Deploying Microservices on Docker • Microservice and any necessary software is “baked” into a Docker Image. • The Image is created based on a Docker file. All necessary set up is specified here. • Docker Images are stored in Docker Registry • Multi-container applications can be defined using Docker compose. • Containers can be deployed as a Cluster using Docker SWARM.
  • 18. 18 Transition from .Net Web Services on IIS • In a recent project we replaced outdated .Net Web Services running on an IIS Service with Java Microservice deployed on Docker in a Wildfly AS . – Good candidate due to few dependencies. – Already separated by product in separate web services – Needed to drastically cut costs – Low risk project since doesn’t provide critical data writes – Other applications in the eco system were already Java based
  • 20. 20 Usage Example: New Architecture
  • 21. 21 Work in Progress • Committing to a microservice architecture beyond a small project is a much bigger undertaking. • Define architecture patterns for cross technology interactions • Define scaling mechanisms • Define state monitoring • Or deploy on AWS or Google to leverage their pre-built tools
  • 22. 22 And now a working Example ! • The following solution imitates the previous architecture. It consists of : – Virtual Machine : Complex Web Application ( Bitcoin Node) – Docker Container : Java Microservice polling the Bitcoin Node – Simple ReactJS Web Page displaying the results.
  • 23. 23 Pre requisites • Install a Bitcoin Node – I used AWS EC2 t2.medium instance w/ 48 GiB volume. – Configure the Security group to allow traffic to our node from other bitcoin nodes and our application.
  • 24. 24 Configure the Bitcoin Node • Install the bitcoin node software on your provisioned server. • Configure the node to accept JSON-RPC requests from our IP only. – sudo vi .bitcoin/bitcoin.conf • Start the bitcoin daemon. Now you can manage it using bitcoin-cli commands – sudo bitcoind –daemon – sudo bitcoin-cli getinfo
  • 25. 25 Writing a Java Microservice • Install Maven, Git, NetBeans (or an IDE of your choice) • Only work on a single resource – Here a Bitcoin Node • Make the end points RESTFUL (PUT, POST, GET) • Use JSON to package objects. • Report Errors • Log
  • 26. 26 Writing a Java Microservice
  • 27. 27 Writing a Java Microservice
  • 28. 28 Wildfy Swarm • Add Wildfly Swarm Dependency & Plugin to package the service into a container in your pom file <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>wildfly-swarm-jaxrs- weld</artifactId> <version>1.0.0.Alpha5-SNAPSHOT</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.2</version> </dependency> … <!-- *** Swarm Plugin *** --> <!-- Specify the main class in your app --> <!-- Executution phase and goal --> <plugin> <groupId>org.wildfly.swarm</groupId> <artifactId>wildfly-swarm- plugin</artifactId> <configuration> <mainClass>com.mius.javajaxrsmicroservic e.JaxRSServriceSwarmMain</mainClass> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin>
  • 29. 29 Could stop here.. • Build the Service and package it into a Swarm Container – mvn clean package • Jar file is fully executable… • Execute using – “java –jar JavaMSDocker-swarm.jar” • but then we wouldn’t get to talk about Docker.
  • 30. 30 Install Docker • https://docs.docker.com/compose/install/ • Depending on your OS you can either run Docker natively or in a VirtualBox • Docker Toolbox installs Docker Machine and other tools like Kitematic.
  • 31. 31 Create a Docker File • Create a file name “Dockerfile” – Specify the base image • FROM java:openjdk-8-jdk – Copy over your files into the container • ADD target/JavaMSDocker-swarm.jar /opt/JavaMSDocker- swarm.jar – Open port 8080 for our Service • EXPOSE 8080 – Configure the container to run as an executable • ENTRYPOINT ["java", "-jar", "/opt/JavaMSDocker- swarm.jar"]
  • 32. 32 Docker Compose • For Development use. Optional. • Define all services to be ran together in a .yml file • Create a file name “docker-compose.yml” wildflyswarm: // define service name build: . // path to the Dockerfile ports: - "8080:8080" // ports to expose HOST:CONTAINER
  • 33. 33 Create your Docker Image • Run the following commands : docker-compose build docker run –p 8080:8080 javamsdocker_wildflyswarm Or docker-compose up
  • 35. 35 React Page to display the data • For simplicity uses simple jquery to GET the bitcoin node status from the java microservice • Uses virtual DOM • JSX transforms in browser
  • 37. 37 References https://en.wikipedia.org/wiki/Microservices http://blog.arungupta.me/microservices-monoliths-noops/ https://www.voxxed.com/blog/2015/04/coupling-versus-autonomy-in-microservices/ http://www.javacodegeeks.com/2015/04/microservice-design-patterns.html http://www.cio.com/article/2924995/enterprise-software/what-are-containers-and-why-do-you-need-them.html https://docs.docker.com/introduction/understanding-docker/ http://wildfly.org/swarm/ http://tutorialzine.com/2014/07/5-practical-examples-for-learning-facebooks-react-framework/ http://blog.arungupta.me/deploy-javaee-docker-swarm-cluster/ https://bitcoin.org/en/full-node#ubuntu-1410
  • 38. 38 Pull this GitHub Repo for the Bitcoin Monitor Demo https://github.com/lana- vk/JavaMicroServiceDocker
  • 39. 39 Thank You ! Lana Kalashnyk W Consulting Group wcgp.co Twitter : @lana_vk
  • 40. Please Leave Feedback During Q&A If you leave session feedback and provide contact information in the survey, you will be qualified for a prize Scan the QR Code to the right or go to http://bit.ly/1K1Hvi5
  • 41. Thanks to all our Sponsors!