-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
68 lines (52 loc) · 1.59 KB
/
Dockerfile
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Settings.
ARG USER_ID=3001
ARG USER_NAME=iriif
ARG SOURCE_DIR=/$USER_NAME/source
# Maven stage.
FROM maven:3-openjdk-11-slim as maven
ARG USER_ID
ARG USER_NAME
ARG SOURCE_DIR
# Create the user and group (use a high ID to attempt to avoid conflicts).
RUN groupadd --non-unique -g $USER_ID $USER_NAME && \
useradd --non-unique -d /$USER_NAME -m -u $USER_ID -g $USER_ID $USER_NAME
# Update the system and install dependencies.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Make sure source directory exists.
RUN mkdir -p $SOURCE_DIR && \
chown -R $USER_ID:$USER_ID $SOURCE_DIR
# Set deployment directory.
WORKDIR $SOURCE_DIR
# Copy files over.
COPY ./pom.xml ./pom.xml
COPY ./src ./src
# Assign file permissions.
RUN chown -R ${USER_ID}:${USER_ID} ${SOURCE_DIR}
# Login as user.
USER $USER_NAME
# Build.
RUN mvn package -Pjar -DskipTests=true
# Switch to Normal JRE Stage.
FROM openjdk:11-jre-slim
ARG USER_ID
ARG USER_NAME
ARG SOURCE_DIR
# Update the system and install dependencies.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create the user and group (use a high ID to attempt to avoid conflicts).
RUN groupadd --non-unique -g $USER_ID $USER_NAME && \
useradd --non-unique -d /$USER_NAME -m -u $USER_ID -g $USER_ID $USER_NAME
# Login as user.
USER $USER_NAME
# Set deployment directory.
WORKDIR /$USER_NAME
# Copy over the built artifact from the maven image.
COPY --from=maven $SOURCE_DIR/target/ROOT.jar ./iriif.jar
# Run java command.
CMD ["java", "-jar", "./iriif.jar"]