-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathDockerfile
35 lines (27 loc) · 982 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
# Multistage Dockerfile for building random-generator
FROM eclipse-temurin:17-jdk as BUILD
ARG VERSION=v1
RUN apt-get update -y \
&& apt-get install -y maven
# Copy over source into the container
COPY spring /opt/random-generator/spring
COPY pom.xml /opt/random-generator
WORKDIR /opt/random-generator
# Build jar files
RUN mvn install -P ${VERSION} -f spring/pom.xml
# --------------------------------
# Runtime image
FROM eclipse-temurin:17-jre
# Copy over artifacts
COPY --from=BUILD /opt/random-generator/spring/target/random-generator*jar /opt/random-generator.jar
COPY --from=BUILD /opt/random-generator/spring/target/classes/RandomRunner.class /opt
COPY random-generator-runner /usr/local/bin
RUN chmod a+x /usr/local/bin/random-generator-runner
# Setup env
WORKDIR /opt
EXPOSE 8080
# We need root for some examples that write to PVs. However, if possible
# you should avoid this
USER 0
# Execute jar file
ENTRYPOINT [ "java", "-jar", "/opt/random-generator.jar" ]