
# First stage - Compiling application
FROM registry.cn-hangzhou.aliyuncs.com/acs/maven:3-jdk-8 AS build-env

ENV MY_HOME=/app
RUN mkdir -p $MY_HOME
WORKDIR $MY_HOME
ADD pom.xml $MY_HOME

# add source
ADD . $MY_HOME

# 下载maven缓存包并解压
RUN ["wget","-O","/home/cache.tar.gz","http://172.19.131.107:18800/cache/maven?name=repository"]
RUN ["tar", "-zxvf", "/home/cache.tar.gz","-C","/home"]
# get all the downloads out of the way
#RUN ["/usr/local/bin/mvn-entrypoint.sh","mvn","verify","clean","--fail-never"]

# run maven verify
RUN ["/usr/local/bin/mvn-entrypoint.sh","mvn","verify","--settings=/home/app/settings.xml" ]

# 打包maven缓存包并上传到服务器
WORKDIR /home
RUN ["tar", "-zcvf", "cache.tar.gz", "app"]
RUN ["curl","-F","file=@/home/cache.tar.gz","http://172.19.131.107:18800/cache/maven?name=repository"]
WORKDIR $MY_HOME

# Second stage - build image
FROM openjdk:8-jre-alpine

COPY --from=build-env /app/ruoyi-admin/target/*.jar /app.jar

ENV JAVA_OPTS=""
ENV SERVER_PORT 8082

EXPOSE ${SERVER_PORT}

ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/urandom -jar /app.jar" ]