Files
Spring-cloud-2025.1.1/a-service/Dockerfile

37 lines
1.6 KiB
Docker
Raw Normal View History

2026-02-10 08:22:09 +08:00
FROM openjdk:25-jdk-slim
WORKDIR /app
COPY target/*.jar app.jar
EXPOSE 8091
ENTRYPOINT ["java","-jar", "app.jar"]
## Perform the extraction in a separate builder container
#FROM bellsoft/liberica-openjre-debian:25-cds AS builder
#WORKDIR /builder
## This points to the built jar file in the target folder
## Adjust this to 'build/libs/*.jar' if you're using Gradle
#ARG JAR_FILE=target/*.jar
## Copy the jar file to the working directory and rename it to application.jar
#COPY ${JAR_FILE} application.jar
## Extract the jar file using an efficient layout
#RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
#
## This is the runtime container
#FROM bellsoft/liberica-openjre-debian:25-cds
#WORKDIR /application
## Copy the extracted jar contents from the builder container into the working directory in the runtime container
## Every copy step creates a new docker layer
## This allows docker to only pull the changes it really needs
#COPY --from=builder /builder/extracted/dependencies/ ./
#COPY --from=builder /builder/extracted/spring-boot-loader/ ./
#COPY --from=builder /builder/extracted/snapshot-dependencies/ ./
#COPY --from=builder /builder/extracted/application/ ./
## Execute the AOT cache training run
#RUN java -XX:AOTCacheOutput=app.aot -Dspring.context.exit=onRefresh -jar application.jar
## Start the application jar with AOT cache enabled - this is not the uber jar used by the builder
## This jar only contains application code and references to the extracted jar files
## This layout is efficient to start up and AOT cache friendly
#ENTRYPOINT ["java", "-XX:AOTCache=app.aot", "-jar", "application.jar"]