SlideShare a Scribd company logo
1 of 28
Download to read offline
SPRING BOOT DANS UNSPRING BOOT DANS UN
CONTAINERCONTAINER
OUTILS ET PRATIQUESOUTILS ET PRATIQUES
PIVOTAL PARISPIVOTAL PARIS
04 / 07 / 201904 / 07 / 2019
DANIEL GARNIER-MOIROUXDANIEL GARNIER-MOIROUX
So ware Engineer @ Pivotal Labs
@Kehrlann
github.com/kehrlann/spring-boot-in-a-container
QUI UTILISE DES CONTAINERS EN PRODUCTIONQUI UTILISE DES CONTAINERS EN PRODUCTION
AUJOURD'HUI ?AUJOURD'HUI ?
CHOIX DE L'IMAGE DE BASECHOIX DE L'IMAGE DE BASE
DOCKERFILE, V1.0DOCKERFILE, V1.0
FROM ubuntu:latest
RUN apt update && apt install openjdk-8-jre -y
COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
UN PEU MIEUX...UN PEU MIEUX...
FROM openjdk:8-jre
COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
PLUS LÉGER !PLUS LÉGER !
FROM openjdk:8-jre-alpine
COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
ENCORE MOINS DE SURFACEENCORE MOINS DE SURFACE
(... mais un peu plus gros en taille)
FROM gcr.io/distroless/java
COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar
CMD ["/app.jar"]
IMAGE DE BASE - TAKE-AWAYSIMAGE DE BASE - TAKE-AWAYS
Container != VM
Utiliser une image spécialisée
Penser à la taille (ex: alpine)
Penser à la sécurité (ex: distroless)
INTERLUDEINTERLUDE
VIRTUALISATIONVIRTUALISATION
CONTAINERSCONTAINERS
LES LAYERS: COMMENT ÇA MARCHELES LAYERS: COMMENT ÇA MARCHE
LES LAYERSLES LAYERS
FROM réutilise toutes les layers de l'image de base.
Les layers sont créées par :
RUN
COPY
ADD
LES LAYERS: RÉUTILISATIONLES LAYERS: RÉUTILISATION
REVENONS À NOS MOUTONS ...REVENONS À NOS MOUTONS ...
FROM gcr.io/distroless/java
COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar
CMD ["/app.jar"]
LAYERING: EXTRACTION DES DÉPENDANCESLAYERING: EXTRACTION DES DÉPENDANCES
DEPS_FOLDER=$PWD/spring-petclinic/target/dependency
mkdir -p "$DEPS_FOLDER"
cd "$DEPS_FOLDER"
jar -xf ../*.jar
LAYERING: CRÉATION DE L'IMAGELAYERING: CRÉATION DE L'IMAGE
FROM gcr.io/distroless/java
ARG DEPENDENCY=spring-petclinic/target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT [
"java",
"-cp",
"app:app/lib/*",
"org.springframework.samples.petclinic.PetClinicApplication"
]
CONSTRUIRE SES IMAGES - TAKE-AWAYSCONSTRUIRE SES IMAGES - TAKE-AWAYS
Choisir son image de base (taille, sécurité, ...)
Séparer dépendances & code dans des layers séparées
BUILD PROCESSBUILD PROCESS
MULTI-STAGE BUILDSMULTI-STAGE BUILDS
# BUILD SOURCE
FROM openjdk:8-jdk-alpine as build
WORKDIR /workspace/spring-petclinic/
COPY spring-petclinic/mvnw .
COPY spring-petclinic/.mvn .mvn
COPY spring-petclinic/pom.xml .
COPY spring-petclinic/src src
RUN ./mvnw package -DskipTests
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
# BUILD IMAGE
FROM gcr.io/distroless/java
ARG DEPENDENCY=/workspace/spring-petclinic/target/dependency
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT [
"java",
"-cp",
"app:app/lib/*",
"org.springframework.samples.petclinic.PetClinicApplication"
]
MULTI-STAGE BUILDS, WITH CACHINGMULTI-STAGE BUILDS, WITH CACHING
# BUILD SOURCE
FROM openjdk:8-jdk-alpine as build
WORKDIR /workspace/spring-petclinic/
COPY spring-petclinic/mvnw .
COPY spring-petclinic/.mvn .mvn
COPY spring-petclinic/pom.xml .
COPY spring-petclinic/src src
RUN --mount=type=cache,target=/root/.m2 ./mvnw clean package -DskipTests
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
# BUILD IMAGE
FROM gcr.io/distroless/java
ARG DEPENDENCY=/workspace/spring-petclinic/target/dependency
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT [
"java",
"-cp",
"app:app/lib/*",
"org.springframework.samples.petclinic.PetClinicApplication"
]
REALLY ?REALLY ?
GOOGLE JIBGOOGLE JIB
Dans votre pom.xml, il suffit d'ajouter:
Puis, run:
Voire:
<build>
[...]
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<to>
<image>kehrlann/pet-clinic:jib</image>
</to>
</configuration>
</plugin>
</plugins>
</build>
$ mvn compile jib:dockerBuild
$ mvn compile jib:build
ALSO, CLOUD-NATIVE BUILDPACKSALSO, CLOUD-NATIVE BUILDPACKS
Build from source !
$ pack build kehrlann/pet-clinic:pack-cf-cn-buildpack --builder=cloudfoundry/cnb
BUILD PROCESS - TAKE-AWAYSBUILD PROCESS - TAKE-AWAYS
Le process de build, c'est important
Mais si on peut éviter d'y penser, c'est mieux
Standardiser la création d'images, c'est top
A VOTRE TOUR !A VOTRE TOUR !
Faites moi signe: @Kehrlann
https://spring.io/guides/topicals/spring-boot-docker/
https://github.com/Kehrlann/spring-boot-in-a-container/

More Related Content

What's hot

What's hot (20)

Serverless Functions: Accelerating DevOps Adoption
Serverless Functions: Accelerating DevOps AdoptionServerless Functions: Accelerating DevOps Adoption
Serverless Functions: Accelerating DevOps Adoption
 
End-to-end test automation with Endtest.dev
End-to-end test automation with Endtest.devEnd-to-end test automation with Endtest.dev
End-to-end test automation with Endtest.dev
 
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
 
Tooling Matters - Development tools
Tooling Matters - Development toolsTooling Matters - Development tools
Tooling Matters - Development tools
 
Building and Running Workloads the Knative Way
Building and Running Workloads the Knative WayBuilding and Running Workloads the Knative Way
Building and Running Workloads the Knative Way
 
GitOps is the best modern practice for CD with Kubernetes
GitOps is the best modern practice for CD with KubernetesGitOps is the best modern practice for CD with Kubernetes
GitOps is the best modern practice for CD with Kubernetes
 
The what, why and how of knative
The what, why and how of knativeThe what, why and how of knative
The what, why and how of knative
 
AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...
AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...
AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...
 
Operator development made easy with helm
Operator development made easy with helmOperator development made easy with helm
Operator development made easy with helm
 
Reactive Microservices with Quarkus
Reactive Microservices with QuarkusReactive Microservices with Quarkus
Reactive Microservices with Quarkus
 
Is your kubernetes negative or positive
Is your kubernetes negative or positive Is your kubernetes negative or positive
Is your kubernetes negative or positive
 
Spring Boot apps in Kubernetes
Spring Boot apps in KubernetesSpring Boot apps in Kubernetes
Spring Boot apps in Kubernetes
 
AWS Community Day Bangkok 2019 - Hello ClaudiaJS
AWS Community Day Bangkok 2019 - Hello ClaudiaJSAWS Community Day Bangkok 2019 - Hello ClaudiaJS
AWS Community Day Bangkok 2019 - Hello ClaudiaJS
 
Serverless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhiskServerless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhisk
 
Developing Serverless Applications on Kubernetes with Knative - OSCON 2019
Developing Serverless Applications on Kubernetes with Knative - OSCON 2019Developing Serverless Applications on Kubernetes with Knative - OSCON 2019
Developing Serverless Applications on Kubernetes with Knative - OSCON 2019
 
2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new
 
WJAX 2013: Java8-Tooling in Eclipse
WJAX 2013: Java8-Tooling in EclipseWJAX 2013: Java8-Tooling in Eclipse
WJAX 2013: Java8-Tooling in Eclipse
 
Helm at reddit: from local dev, staging, to production
Helm at reddit: from local dev, staging, to productionHelm at reddit: from local dev, staging, to production
Helm at reddit: from local dev, staging, to production
 
Going Serverless with Kubeless In Google Container Engine (GKE)
Going Serverless with Kubeless In Google Container Engine (GKE)Going Serverless with Kubeless In Google Container Engine (GKE)
Going Serverless with Kubeless In Google Container Engine (GKE)
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with Gitlab
 

Similar to SPRING BOOT DANS UN CONTAINER OUTILS ET PRATIQUES

TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
Amazon Web Services
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
Evan Schultz
 
From ci to cd - LavaJug 2012
From ci to cd  - LavaJug 2012From ci to cd  - LavaJug 2012
From ci to cd - LavaJug 2012
Henri Gomez
 

Similar to SPRING BOOT DANS UN CONTAINER OUTILS ET PRATIQUES (20)

Repeatable Deployments and Installations
Repeatable Deployments and InstallationsRepeatable Deployments and Installations
Repeatable Deployments and Installations
 
Minimum Viable Docker: our journey towards orchestration
Minimum Viable Docker: our journey towards orchestrationMinimum Viable Docker: our journey towards orchestration
Minimum Viable Docker: our journey towards orchestration
 
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
TLS303 How to Deploy Python Applications on AWS Elastic Beanstalk - AWS re:In...
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
 
Vagrant or docker for java dev environment
Vagrant or docker for java dev environmentVagrant or docker for java dev environment
Vagrant or docker for java dev environment
 
Node Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsNode Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.js
 
Developing and deploying applications with Spring Boot and Docker (@oakjug)
Developing and deploying applications with Spring Boot and Docker (@oakjug)Developing and deploying applications with Spring Boot and Docker (@oakjug)
Developing and deploying applications with Spring Boot and Docker (@oakjug)
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for Docker
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
 
DockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best PracticesDockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best Practices
 
DCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best PracticesDCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best Practices
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Deploy Deep Learning Application with Azure Container Instance - Devdays2018
Deploy Deep Learning Application with Azure Container Instance - Devdays2018Deploy Deep Learning Application with Azure Container Instance - Devdays2018
Deploy Deep Learning Application with Azure Container Instance - Devdays2018
 
How we integrate & deploy Mobile Apps with Travis CI
How we integrate & deploy Mobile Apps with Travis CIHow we integrate & deploy Mobile Apps with Travis CI
How we integrate & deploy Mobile Apps with Travis CI
 
London Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.jsLondon Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.js
 
From ci to cd - LavaJug 2012
From ci to cd  - LavaJug 2012From ci to cd  - LavaJug 2012
From ci to cd - LavaJug 2012
 
Spryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetes
Spryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetesSpryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetes
Spryker meetup-distribute-your-spryker-deployment-with-docker-and-kubernetes
 
Odoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenvOdoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenv
 
Intro to Continuous Integration at SoundCloud
Intro to Continuous Integration at SoundCloudIntro to Continuous Integration at SoundCloud
Intro to Continuous Integration at SoundCloud
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 

More from VMware Tanzu

More from VMware Tanzu (20)

What AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About ItWhat AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About It
 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023
 
Enhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at ScaleEnhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at Scale
 
Spring Update | July 2023
Spring Update | July 2023Spring Update | July 2023
Spring Update | July 2023
 
Platforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a ProductPlatforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a Product
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdfSpring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
 
Tanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchTanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - French
 
Tanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishTanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - English
 
Virtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVirtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
 
Tanzu Developer Connect - French
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - French
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
 
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerSpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software Engineer
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeSpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs Practice
 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsSpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

SPRING BOOT DANS UN CONTAINER OUTILS ET PRATIQUES

  • 1. SPRING BOOT DANS UNSPRING BOOT DANS UN CONTAINERCONTAINER OUTILS ET PRATIQUESOUTILS ET PRATIQUES PIVOTAL PARISPIVOTAL PARIS 04 / 07 / 201904 / 07 / 2019
  • 2. DANIEL GARNIER-MOIROUXDANIEL GARNIER-MOIROUX So ware Engineer @ Pivotal Labs @Kehrlann github.com/kehrlann/spring-boot-in-a-container
  • 3. QUI UTILISE DES CONTAINERS EN PRODUCTIONQUI UTILISE DES CONTAINERS EN PRODUCTION AUJOURD'HUI ?AUJOURD'HUI ?
  • 4. CHOIX DE L'IMAGE DE BASECHOIX DE L'IMAGE DE BASE
  • 5. DOCKERFILE, V1.0DOCKERFILE, V1.0 FROM ubuntu:latest RUN apt update && apt install openjdk-8-jre -y COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar ENTRYPOINT ["java","-jar","/app.jar"]
  • 6. UN PEU MIEUX...UN PEU MIEUX... FROM openjdk:8-jre COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar ENTRYPOINT ["java","-jar","/app.jar"]
  • 7. PLUS LÉGER !PLUS LÉGER ! FROM openjdk:8-jre-alpine COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar ENTRYPOINT ["java","-jar","/app.jar"]
  • 8. ENCORE MOINS DE SURFACEENCORE MOINS DE SURFACE (... mais un peu plus gros en taille) FROM gcr.io/distroless/java COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar CMD ["/app.jar"]
  • 9. IMAGE DE BASE - TAKE-AWAYSIMAGE DE BASE - TAKE-AWAYS Container != VM Utiliser une image spécialisée Penser à la taille (ex: alpine) Penser à la sécurité (ex: distroless)
  • 13. LES LAYERS: COMMENT ÇA MARCHELES LAYERS: COMMENT ÇA MARCHE
  • 14. LES LAYERSLES LAYERS FROM réutilise toutes les layers de l'image de base. Les layers sont créées par : RUN COPY ADD
  • 15. LES LAYERS: RÉUTILISATIONLES LAYERS: RÉUTILISATION
  • 16. REVENONS À NOS MOUTONS ...REVENONS À NOS MOUTONS ... FROM gcr.io/distroless/java COPY spring-petclinic/target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar /app.jar CMD ["/app.jar"]
  • 17. LAYERING: EXTRACTION DES DÉPENDANCESLAYERING: EXTRACTION DES DÉPENDANCES DEPS_FOLDER=$PWD/spring-petclinic/target/dependency mkdir -p "$DEPS_FOLDER" cd "$DEPS_FOLDER" jar -xf ../*.jar
  • 18. LAYERING: CRÉATION DE L'IMAGELAYERING: CRÉATION DE L'IMAGE FROM gcr.io/distroless/java ARG DEPENDENCY=spring-petclinic/target/dependency COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib COPY ${DEPENDENCY}/META-INF /app/META-INF COPY ${DEPENDENCY}/BOOT-INF/classes /app ENTRYPOINT [ "java", "-cp", "app:app/lib/*", "org.springframework.samples.petclinic.PetClinicApplication" ]
  • 19. CONSTRUIRE SES IMAGES - TAKE-AWAYSCONSTRUIRE SES IMAGES - TAKE-AWAYS Choisir son image de base (taille, sécurité, ...) Séparer dépendances & code dans des layers séparées
  • 21. MULTI-STAGE BUILDSMULTI-STAGE BUILDS # BUILD SOURCE FROM openjdk:8-jdk-alpine as build WORKDIR /workspace/spring-petclinic/ COPY spring-petclinic/mvnw . COPY spring-petclinic/.mvn .mvn COPY spring-petclinic/pom.xml . COPY spring-petclinic/src src RUN ./mvnw package -DskipTests RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) # BUILD IMAGE FROM gcr.io/distroless/java ARG DEPENDENCY=/workspace/spring-petclinic/target/dependency COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app ENTRYPOINT [ "java", "-cp", "app:app/lib/*", "org.springframework.samples.petclinic.PetClinicApplication" ]
  • 22. MULTI-STAGE BUILDS, WITH CACHINGMULTI-STAGE BUILDS, WITH CACHING # BUILD SOURCE FROM openjdk:8-jdk-alpine as build WORKDIR /workspace/spring-petclinic/ COPY spring-petclinic/mvnw . COPY spring-petclinic/.mvn .mvn COPY spring-petclinic/pom.xml . COPY spring-petclinic/src src RUN --mount=type=cache,target=/root/.m2 ./mvnw clean package -DskipTests RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) # BUILD IMAGE FROM gcr.io/distroless/java ARG DEPENDENCY=/workspace/spring-petclinic/target/dependency COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app ENTRYPOINT [ "java", "-cp", "app:app/lib/*", "org.springframework.samples.petclinic.PetClinicApplication" ]
  • 24. GOOGLE JIBGOOGLE JIB Dans votre pom.xml, il suffit d'ajouter: Puis, run: Voire: <build> [...] <plugins> <plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>jib-maven-plugin</artifactId> <version>1.3.0</version> <configuration> <to> <image>kehrlann/pet-clinic:jib</image> </to> </configuration> </plugin> </plugins> </build> $ mvn compile jib:dockerBuild $ mvn compile jib:build
  • 25. ALSO, CLOUD-NATIVE BUILDPACKSALSO, CLOUD-NATIVE BUILDPACKS Build from source ! $ pack build kehrlann/pet-clinic:pack-cf-cn-buildpack --builder=cloudfoundry/cnb
  • 26.
  • 27. BUILD PROCESS - TAKE-AWAYSBUILD PROCESS - TAKE-AWAYS Le process de build, c'est important Mais si on peut éviter d'y penser, c'est mieux Standardiser la création d'images, c'est top
  • 28. A VOTRE TOUR !A VOTRE TOUR ! Faites moi signe: @Kehrlann https://spring.io/guides/topicals/spring-boot-docker/ https://github.com/Kehrlann/spring-boot-in-a-container/