FROM openjdk:8-jdk-alpine

ARG ARG_APP_NAME
ARG ARG_DEPLOY_PATH
ARG ROOT_PATH
ARG APP_MODULE_PATH=""

ARG PORT


ENV TIME_ZONE Asia/Shanghai

ENV APP_NAME=${ARG_APP_NAME}

ENV DEPLOY_PATH=${ARG_DEPLOY_PATH}

ENV APP_LOG_DIR=/data/${APP_NAME}/logs/app

ENV TOMCAT_LOG_DIR=/data/${APP_NAME}/logs/tomcat

ENV HEAP_DUMP_PATH=/data/${APP_NAME}/logs/heap-dump

ENV RUOYI_UPLOAD_PATH=/data/${APP_NAME}/ruoyi/uploadPath

ENV JVM_OPTION_THREAD_STACK_SIZE=512k

ENV JVM_OPTION_NETWORK_ADDRESS_CACHE_TTL=10

ENV JVM_OPTION_MAX_DIRECT_MEMORY_SIZE=512m

ENV JVM_OPTION_MAX_METASPACE_SIZE=256m

ENV JVM_OPTION_RESERVED_CODE_CACHE_SIZE=256m

ENV JVM_MAX_GC_PAUSE_MILLS=50

ENV SERVER_PORT=${PORT}

ENV JAVA_OPTS = ""
WORKDIR ${DEPLOY_PATH}/${APP_NAME}
RUN ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime

RUN mkdir -p ${APP_LOG_DIR}

RUN mkdir -p ${TOMCAT_LOG_DIR}

RUN mkdir -p ${HEAP_DUMP_PATH}

RUN mkdir -p ${RUOYI_UPLOAD_PATH}

RUN apk add --update font-adobe-100dpi ttf-dejavu fontconfig

ADD ${ROOT_PATH}${APP_MODULE_PATH}/target/${APP_NAME}.jar ./

EXPOSE ${SERVER_PORT}


ENTRYPOINT ["/bin/sh","-c","java -XX:ThreadStackSize=512k -Dfile.encoding=UTF-8 -Xms512m -Xmx1024m -XX:MaxMetaspaceSize=512m -XX:+PrintGCDetails -XX:NewRatio=1 -XX:+UseParallelOldGC -jar $APP_NAME.jar"]
