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 elastic-job-lite /elastic-job-lite

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

RUN mvn install -DskipTests -f /elastic-job-lite/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 /elastic-job-lite/entrypoint.sh entrypoint.sh

RUN chmod a+x /entrypoint.sh


ENTRYPOINT /entrypoint.sh
