-
-
Save naviat/e404f0577751f94c8318f86464dce325 to your computer and use it in GitHub Desktop.
Dockerfile including open jdk8 + maven 3.6.1 + gradle 4.0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM openjdk:8-jdk-alpine | |
LABEL Miguel Doctor <[email protected]> | |
RUN apk add --no-cache curl tar bash procps | |
# Downloading and installing Maven | |
ARG MAVEN_VERSION=3.6.1 | |
ARG USER_HOME_DIR="/root" | |
ARG SHA=b4880fb7a3d81edd190a029440cdf17f308621af68475a4fe976296e71ff4a4b546dd6d8a58aaafba334d309cc11e638c52808a4b0e818fc0fd544226d952544 | |
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries | |
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ | |
&& echo "Downlaoding maven" \ | |
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ | |
\ | |
&& echo "Checking download hash" \ | |
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \ | |
\ | |
&& echo "Unziping maven" \ | |
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ | |
\ | |
&& echo "Cleaning and setting links" \ | |
&& 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" | |
# Downloading and installing Gradle | |
# 1- Define a constant with the version of gradle you want to install | |
ARG GRADLE_VERSION=4.0.1 | |
# 2- Define the URL where gradle can be downloaded from | |
ARG GRADLE_BASE_URL=https://services.gradle.org/distributions | |
# 3- Define the SHA key to validate the gradle download | |
# obtained from here https://gradle.org/release-checksums/ | |
ARG GRADLE_SHA=d717e46200d1359893f891dab047fdab98784143ac76861b53c50dbd03b44fd4 | |
# 4- Create the directories, download gradle, validate the download, install it, remove downloaded file and set links | |
RUN mkdir -p /usr/share/gradle /usr/share/gradle/ref \ | |
&& echo "Downlaoding gradle hash" \ | |
&& curl -fsSL -o /tmp/gradle.zip ${GRADLE_BASE_URL}/gradle-${GRADLE_VERSION}-bin.zip \ | |
\ | |
&& echo "Checking download hash" \ | |
&& echo "${GRADLE_SHA} /tmp/gradle.zip" | sha256sum -c - \ | |
\ | |
&& echo "Unziping gradle" \ | |
&& unzip -d /usr/share/gradle /tmp/gradle.zip \ | |
\ | |
&& echo "Cleaning and setting links" \ | |
&& rm -f /tmp/gradle.zip \ | |
&& ln -s /usr/share/gradle/gradle-${GRADLE_VERSION} /usr/bin/gradle | |
# 5- Define environmental variables required by gradle | |
ENV GRADLE_VERSION 4.0.1 | |
ENV GRADLE_HOME /usr/bin/gradle | |
ENV GRADLE_USER_HOME /cache | |
ENV PATH $PATH:$GRADLE_HOME/bin | |
VOLUME $GRADLE_USER_HOME | |
CMD [""] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment