cigs4/Dockerfile

57 wiersze
2.1 KiB
Docker
Czysty Wina Historia

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#FROM maven:3-jdk-8-alpine as builder
#WORKDIR /app
#COPY settings.xml /usr/share/maven/ref/repository/settings.xml
#COPY pom.xml .
#COPY gateway/pom.xml gateway/
#COPY core/pom.xml core/
#COPY common/pom.xml common/
#COPY passport/pom.xml passport/
#COPY upms/pom.xml upms/
#COPY empty/pom.xml empty/
#COPY material/pom.xml material/
#COPY order/pom.xml order/
#COPY monitor/pom.xml monitor/
#COPY equipment/pom.xml equipment/
#COPY basic/pom.xml basic/
## COPY report/pom.xml report/
#
#RUN mvn -B -s /usr/share/maven/ref/repository/settings.xml dependency:resolve-plugins dependency:resolve clean package
#
#COPY ./ ./
#
#RUN mvn -B -s /usr/share/maven/ref/repository/settings.xml -Dmaven.test.skip=true -Ptest clean package
FROM maven:3-jdk-8-alpine as builder
WORKDIR /app
COPY ./ ./
RUN mvn -s settings.xml clean package -Dmaven.test.skip=true
FROM anapsix/alpine-java:8_server-jre_unlimited as layers
LABEL mantainer=shihairong@zimonet.com
WORKDIR /app
COPY --from=builder app/ym-gateway/target/ym-gateway.jar /app/app.jar
#ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom","-jar","app.jar", "--spring.profiles.active=dev"]
# 通过工具spring-boot-jarmode-layertools从application.jar中提取拆分后的构建结果
RUN java -Djarmode=layertools -jar app.jar extract
# 正式构建镜像
FROM anapsix/alpine-java:8_server-jre_unlimited
# 指定工作目录,目录不存在会自动创建
WORKDIR /app
# 前一阶段从jar中提取除了多个文件这里分别执行COPY命令复制到镜像空间中每次COPY都是一个layer
COPY --from=layers app/dependencies ./
COPY --from=layers app/spring-boot-loader ./
COPY --from=layers app/snapshot-dependencies ./
COPY --from=layers app/company-dependencies ./
COPY --from=layers app/application ./
# 指定时区
ENV TZ="Asia/Shanghai"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 定义一些环境变量,方便环境变量传参
ENV JVM_OPTS=""
ENV JAVA_OPTS=""
# 指定暴露的端口,起到说明的作用,不指定也会暴露对应端口
EXPOSE 8080
# 启动 jar 的命令
ENTRYPOINT ["sh","-c","java $JVM_OPTS $JAVA_OPTS org.springframework.boot.loader.JarLauncher"]