-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile-template
40 lines (31 loc) · 1.35 KB
/
Dockerfile-template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
FROM openjdk:8-jdk-alpine
# graphviz is required by maven-javadoc-plugin (generate-site)
RUN apk add --no-cache graphviz curl tar bash procps
# Downloading and installing Maven
# 1- Define a constant with the version of maven you want to install
ARG MAVEN_VERSION=3.6.3
# 2- Define a constant with the working directory
ARG USER=<USER>
ARG USER_ID=<USER_ID>
ARG WORK_DIR=<WORK_DIR>
RUN adduser --disabled-password -g '' -u $USER_ID $USER
# 4- Define the URL where maven can be downloaded from
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
# 5- Create the directories, download maven, validate the download, install it, remove downloaded file and set links
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& echo "Downloading maven" \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
\
&& 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
# 6- Setup user dev environment
USER $USER
WORKDIR $WORK_DIR
# 7- Define environmental variables required by Maven, like Maven_Home directory and where the maven repo is located
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER/.m2"
CMD "bash"