FROM maven:3.6.0-alpine

RUN apk add ca-certificates && \
    apk add tzdata && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone

COPY data-elastic-job /data-elastic-job

ENV VERSION 3.0.0.M1
ENV CONSOLE_PATH /data-elastic-job/elastic-job-lite-console
ENV ROOT_USERNAME root
ENV ROOT_PASSWORD root
ENV GUEST_USERNAME guest
ENV GUEST_PASSWORD guest

RUN mvn package -DskipTests -f ${CONSOLE_PATH}/pom.xml \
    # 复制console包
    && mv ${CONSOLE_PATH}/target/elastic-job-lite-console-${VERSION}.tar.gz /elastic-job-lite-console-${VERSION}.tar.gz \
    # 删除源码解压文件夹
    && rm -rf elastic-job-lite-${VERSION} \
    # 解压console
    && tar -zxvf /elastic-job-lite-console-${VERSION}.tar.gz \
    # 删除console压缩包
    && rm -rf /elastic-job-lite-console-${VERSION}.tar.gz

ADD entrypoint.sh entrypoint.sh

RUN chmod a+x /entrypoint.sh

ENTRYPOINT /entrypoint.sh
