FROM anapsix/alpine-java:8u201b09_jdk_unlimited

ENV TZ=Asia/Shanghai \
  MAVEN_VERSION=3.5.4 \
  MAVEN_HOME=/usr/share/maven \
  USER_HOME_DIR="/root" \
  MAVEN_CONFIG="/root/.m2"

RUN set -ex && \
    sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
    apk add --no-cache --virtual=build-dependencies tzdata curl tar unzip libstdc++ && \
    # fix tz
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
    echo $TZ > /etc/timezone && \
    # maven ===
    # 参考 dockette/mvn
    mkdir -p /usr/share/maven /usr/share/maven/ref && \
    mkdir -p $MAVEN_CONFIG/repository && \
    curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
    | tar -xzC /usr/share/maven --strip-components=1 && \
    ln -s /usr/share/maven/bin/mvn /usr/bin/mvn && \
    # cleanup ===
    apk del build-dependencies && \
    rm -rf /tmp/* /var/cache/apk/*

COPY settings.xml $MAVEN_CONFIG

CMD ["mvn"]


