docker/gradle-node/Dockerfile

102 lines
3.4 KiB
Docker
Raw Normal View History

2019-01-08 16:36:25 +08:00
# alpine环境下编译node实在太慢所以以这个为基础镜像比较划算了。
2019-06-03 10:34:15 +08:00
FROM node:12-alpine
2019-01-08 11:45:20 +08:00
2019-01-08 16:36:25 +08:00
MAINTAINER kennylee26 <kennylee26@gmail.com>
2019-01-08 11:45:20 +08:00
2019-06-03 10:59:00 +08:00
ENV ALPINE_VERSION 3.9
2019-01-08 11:45:20 +08:00
# 使用阿里云镜像
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# Install base packages
RUN apk --no-cache update && \
apk --no-cache upgrade && \
2019-01-08 16:36:25 +08:00
apk --no-cache add curl bash tzdata tar unzip xz procps wget git openssh && \
2019-01-08 11:45:20 +08:00
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
2019-01-08 16:36:25 +08:00
echo -ne "Alpine Linux "+ ${ALPINE_VERSION} + " image. (`uname -rsv`)\n" >> /root/.built && \
2019-01-08 11:45:20 +08:00
rm -fr /tmp/* /var/cache/apk/*
2019-01-08 16:36:25 +08:00
ENV LANG C.UTF-8
2019-01-10 16:09:11 +08:00
RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
2019-01-08 16:36:25 +08:00
############## install openjdk 8
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
2019-06-03 10:59:00 +08:00
ENV JAVA_VERSION 8u212
ENV JAVA_ALPINE_VERSION 8.212.04-r0
2019-01-08 16:36:25 +08:00
RUN set -x \
&& apk add --no-cache \
openjdk8="$JAVA_ALPINE_VERSION" \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]
RUN set -o errexit -o nounset \
&& echo "Testing Java installation" \
&& java -version
############## install maven
ARG MAVEN_VERSION=3.6.0
ARG USER_HOME_DIR="/root"
ARG SHA=fae9c12b570c3ba18116a4e26ea524b29f7279c17cbaadc3326ca72927368924d9131d11b9e851b8dc9162228b6fdea955446be41207a5cfc61283dd8a561d2f
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
# 容器内本地maven库
VOLUME /var/maven/repository
ENV MAVEN_SETING_FILE=/usr/share/maven/conf/settings.xml
2019-01-08 16:39:06 +08:00
RUN wget https://gitee.com/kennylee/docker/raw/master/maven/settings.xml
RUN mv settings.xml ${MAVEN_SETING_FILE}
2019-01-08 16:36:25 +08:00
RUN mkdir -p ${MAVEN_CONFIG} && cp ${MAVEN_SETING_FILE} ${MAVEN_CONFIG}
RUN set -o errexit -o nounset \
&& echo "Testing Maven installation" \
&& mvn --version
############## install gradle
ENV GRADLE_HOME /opt/gradle
2019-06-03 10:59:00 +08:00
# 注意SHA256要匹配
2019-06-03 10:34:15 +08:00
ARG GRADLE_VERSION=5.4.1
2019-06-03 10:59:00 +08:00
ARG GRADLE_DOWNLOAD_SHA256=7bdbad1e4f54f13c8a78abc00c26d44dd8709d4aedb704d913fb1bb78ac025dc
2019-01-08 16:36:25 +08:00
ENV GRADLE_VERSION=$GRADLE_VERSION
RUN set -o errexit -o nounset \
&& echo "Downloading Gradle" \
&& wget -qO gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
\
&& echo "Checking download hash" \
&& echo "${GRADLE_DOWNLOAD_SHA256} *gradle.zip" | sha256sum -c - \
\
&& echo "Installing Gradle" \
&& unzip gradle.zip \
&& rm gradle.zip \
&& mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \
&& ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle
VOLUME "/root/.gradle"
RUN set -o errexit -o nounset \
&& echo "Testing Gradle installation" \
&& gradle --version
2019-01-08 11:45:20 +08:00