#基于JDK1.8镜像
FROM registry.cn-shanghai.aliyuncs.com/java_server/java_server:openjdk-8 as build-env
#添加应用jar包
ADD /ruoyi-admin/target/ROOT.jar /tmp/app/ROOT.jar
#构建应用
RUN cd /tmp/app && \
mkdir /app && \
#拷贝编译结果到指定目录
mv /tmp/app/ROOT.jar /app/ROOT.jar && \
#清理编译痕迹
rm -rf /tmp/app
#多阶段构建
FROM registry.cn-shanghai.aliyuncs.com/java_server/java_server:openjdk-jre-alpine-8
#添加阿里云镜像源 添加ttf-dejavu字体镜像 创建文件
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \
&& apk add --no-cache tzdata bash ttf-dejavu fontconfig \
&& fc-cache --force \
&& mkdir /app_home
COPY --from=build-env /app/ROOT.jar /app_home/ROOT.jar
#设置编码格式
#ENV LANG="zh_CN.UTF-8"
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8
VOLUME ["/logs"]
#EXPOSE 8090
#ENTRYPOINT java -server -Dfile.encoding=UTF-8 -Xmx512m -Xss256k -Xdebug -Xnoagent -Djava.compiler=NONE -Dspring.profiles.active=prod -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=50983 -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar
#ENTRYPOINT ["java", "-server", "-Dfile.encoding=UTF-8", "-Xmx512m", "-Xss256k", "-Xdebug", "-Xnoagent", "-Djava.compiler=NONE", "-Dspring.profiles.active=prod", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=50983", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app/ROOT.jar"]
#ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/ROOT.jar"]
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app_home/ROOT.jar","--server.port=8080"]
#构建镜像
#docker build -t shanghaiyeye:[版本号] .