-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
36 lines (27 loc) · 938 Bytes
/
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
# First stage builds the jar and is discarded in the final image
FROM maven:3.6.3-adoptopenjdk-8 AS MAVEN_BUILD
# Copy pom and resolve dependecies for layer caching
COPY pom.xml ./pom.xml
RUN mvn dependency:go-offline
# Copy the source and build the jar
COPY src/ ./src/
RUN mvn clean package
# Build the actual runtime image
FROM openjdk:8-jre-alpine3.9
ARG UNAME=ctt
# The ids should be unique to the container
ARG UID=1586
ARG GID=1586
ENTRYPOINT ["java","-jar","/usr/share/ctt/ctt.jar"]
WORKDIR /usr/share/ctt/
# Add a user and switch to it to avoid running the webserver as root
RUN adduser -D -g "" -u $UID $UNAME $UNAME \
&& mkdir work \
&& chown $UNAME:$UNAME work
USER $UNAME
# Add Maven dependencies
COPY --from=MAVEN_BUILD target/lib/ ./lib/
# Add the service itself
COPY --from=MAVEN_BUILD target/ctt-*-SNAPSHOT.jar ./ctt.jar
# Copy default templates into the container
COPY templates/ ./templates/