使用如下Dockerfile构建镜像

# vim Dockerfile
FROM moxm/java:1.8-full as builder
WORKDIR /build
ARG JAR_FILE=target/pig-register.jar
COPY ${JAR_FILE} app.jar
RUN java -Djarmode=layertools -jar app.jar extract && rm app.jar

FROM openjdk:8-jre
LABEL maintainer="jclazz@outlook.com"
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom"
WORKDIR pig-register

COPY --from=builder /build/dependencies/ ./
COPY --from=builder /build/snapshot-dependencies/ ./
COPY --from=builder /build/spring-boot-loader/ ./
COPY --from=builder /build/application/ ./

EXPOSE 8848

CMD sleep 30; java $JAVA_OPTS org.springframework.boot.loader.JarLauncher

参考:

https://gitee.com/log4j/pig/blob/8ee3bc5a3919043f147ae06ae9e1714a6669d4da/pig-register/Dockerfile

  

posted on 2023-02-28 14:52  a120608yby  阅读(241)  评论(0编辑  收藏  举报