Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dockerfile to install maven
#
# Oracle Java 7 Dockerfile
#
# https://github.com/dockerfile/java
# https://github.com/dockerfile/java/tree/master/oracle-java7
#
# Pull base image.
FROM alpine as build
ARG MAVEN_VERSION=3.6.3
ARG USER_HOME_DIR="/root"
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
# Install Java.
RUN apk --update --no-cache add openjdk7 curl
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 \
&& 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"
# Define working directory.
WORKDIR /data
# Define commonly used JAVA_HOME variable
ENV JAVA_HOME /usr/lib/jvm/default-jvm/
# Define default command.
CMD ["mvn", "--version"]
# Spring docker sample
# FROM openjdk:8-jdk-alpine
# VOLUME /tmp
# ARG JAR_FILE
# COPY ${JAR_FILE} app.jar
# ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
@zerjioang
Copy link

zerjioang commented Apr 19, 2022

@LuanComputacao @antonTroyan you need to update the version defined of MVN to at least 3.6.3. See available versions on remote at: https://apache.osuosl.org/maven/maven-3/

@LuanComputacao
Copy link
Author

LuanComputacao commented Jun 9, 2022

Thanks, @zerjioang
I did the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment