Fix a few indentation issues and content on multi-stage concept (#19942)

Signed-off-by: Michael Irwin <mikesir87@gmail.com>
This commit is contained in:
Michael Irwin 2024-05-08 14:49:02 -04:00 committed by GitHub
parent 4c4c691092
commit 250a952faf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 7 deletions

View File

@ -259,14 +259,15 @@ Now that you have the project, youre ready to create the `Dockerfile`.
1. Consider the following Dockerfile: 1. Consider the following Dockerfile:
```dockerfile ```dockerfile
FROM eclipse-temurin:21.0.2_13-jdk-jammy as builder FROM eclipse-temurin:21.0.2_13-jdk-jammy AS builder
WORKDIR /opt/app WORKDIR /opt/app
COPY .mvn/ .mvn COPY .mvn/ .mvn
COPY mvnw pom.xml ./ COPY mvnw pom.xml ./
RUN ./mvnw dependency:go-offline RUN ./mvnw dependency:go-offline
COPY ./src ./src COPY ./src ./src
RUN ./mvnw clean install RUN ./mvnw clean install
FROM eclipse-temurin:21.0.2_13-jre-jammy as final
FROM eclipse-temurin:21.0.2_13-jre-jammy AS final
WORKDIR /opt/app WORKDIR /opt/app
EXPOSE 8080 EXPOSE 8080
COPY --from=builder /opt/app/target/*.jar /opt/app/*.jar COPY --from=builder /opt/app/target/*.jar /opt/app/*.jar
@ -277,7 +278,7 @@ Now that you have the project, youre ready to create the `Dockerfile`.
- The first stage remains the same as the previous Dockerfile, providing a Java Development Kit (JDK) environment for building the application. This stage is given the name of builder. - The first stage remains the same as the previous Dockerfile, providing a Java Development Kit (JDK) environment for building the application. This stage is given the name of builder.
- The second stage is a new stage named `final`. Since it starts `FROM builder`, it inherits everything from the base stage (JDK environment). It uses a slimmer `eclipse-temurin:21.0.2_13-jre-jammy` image, containing just the Java Runtime Environment (JRE) needed to run the application. This image provides a Java Runtime Environment (JRE) which is enough for running the compiled application (JAR file). - The second stage is a new stage named `final`. It uses a slimmer `eclipse-temurin:21.0.2_13-jre-jammy` image, containing just the Java Runtime Environment (JRE) needed to run the application. This image provides a Java Runtime Environment (JRE) which is enough for running the compiled application (JAR file).
> For production use, it's highly recommended that you produce a custom JRE-like runtime using jlink. JRE images are available for all versions of Eclipse Temurin, but `jlink` allows you to create a minimal runtime containing only the necessary Java modules for your application. This can significantly reduce the size and improve the security of your final image. [Refer to this page](https://hub.docker.com/_/eclipse-temurin) for more information. > For production use, it's highly recommended that you produce a custom JRE-like runtime using jlink. JRE images are available for all versions of Eclipse Temurin, but `jlink` allows you to create a minimal runtime containing only the necessary Java modules for your application. This can significantly reduce the size and improve the security of your final image. [Refer to this page](https://hub.docker.com/_/eclipse-temurin) for more information.