Spring Boot 分层构建 Docker 镜像
Spring Boot Docker About 997 words查看分层文件夹
PS D:\demo\target> java -Djarmode=layertools -jar .\demo-0.0.1-SNAPSHOT.jar list
dependencies
spring-boot-loader
snapshot-dependencies
application
解压分层文件夹
PS D:\demo\target> java -Djarmode=layertools -jar .\demo-0.0.1-SNAPSHOT.jar extract
分层构建
FROM eclipse-temurin:11-jre as builder
WORKDIR application
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM eclipse-temurin:11-jre
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
优点
使用Docker
缓存层加速构建。
自定义分层构建
参考
https://docs.spring.io/spring-boot/docs/current/reference/html/container-images.html
Views: 1,466 · Posted: 2022-10-10
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...