springboot项目docker打包Dockerfile
Posted gsls200808
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot项目docker打包Dockerfile相关的知识,希望对你有一定的参考价值。
新建Dockerfile
内容如下
FROM openjdk:8u272-jdk as builder
WORKDIR application
ARG JAR_FILE=target/app-2.0.jar
COPY $JAR_FILE application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM openjdk:8u272-jdk
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/application/ ./
COPY docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
ENTRYPOINT ["./docker-entrypoint.sh"]
新建docker-entrypoint.sh,内容如下
#!/bin/bash
java $JAVA_OPTS -server \\
-XX:+UnlockExperimentalVMOptions \\
-XX:+UseCGroupMemoryLimitForHeap \\
-XX:-OmitStackTraceInFastThrow \\
-Djava.security.egd=file:/dev/./urandom \\
org.springframework.boot.loader.JarLauncher
以上是关于springboot项目docker打包Dockerfile的主要内容,如果未能解决你的问题,请参考以下文章
docker 运行jenkins及vue项目与springboot项目(四.docker运行nginx)
docker 运行jenkins及vue项目与springboot项目(五.jenkins打包springboot服务且在docker中运行)