Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Spring Boot 2.0

You're reading from   Mastering Spring Boot 2.0 Build modern, cloud-native, and distributed systems using Spring Boot

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781787127562
Length 390 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dinesh Rajput Dinesh Rajput
Author Profile Icon Dinesh Rajput
Dinesh Rajput
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Getting Started with Spring Boot 2.0 2. Customizing Auto-Configuration in Spring Boot Application FREE CHAPTER 3. Getting Started with Spring CLI and Actuator 4. Getting Started with Spring Cloud and Configuration 5. Spring Cloud Netflix and Service Discovery 6. Building Spring Boot RESTful Microservice 7. Creating API Gateway with Netflix Zuul Proxy 8. Simplify HTTP API with Feign Client 9. Building Event-Driven and Asynchronous Reactive Systems 10. Building Resilient Systems Using Hystrix and Turbine 11. Testing Spring Boot Application 12. Containerizing Microservice 13. API Management 14. Deploying in Cloud (AWS) 15. Production Ready Service Monitoring and Best Practices 16. Other Books You May Enjoy

Dockerizing any Spring Boot application


In this section, I'll focus on how to dockerize a Spring Boot application (Account-Service) to run in an isolated environment, which is a container. In the previous chapters, we have created some microservices, such as Account-Service and Customer-Service. Now I will describe the process of migrating a Spring Boot Account-Service to Docker. We will start by modifying a build file, then we will create Dockerfile so it can be run locally.

So let's go ahead and create Dockerfile in our Spring Boot project:

#This is a Dockerfile for a microservice application 
 
# Use an official Java 8 runtime as a parent image 
FROM maven:3.5-jdk-8-alpine 
 
VOLUME /tmp 
 
#Set maintainer email id 
MAINTAINER [email protected]  
 
# Set the working directory to /app 
WORKDIR /app 
 
# Copy the current directory contents into the container at /app 
ADD . /app 
 
# Build and create jar using maven command 
#RUN mvn package -DskipTests=true -Ddir=app 
 
# Copy the current...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image