forked from jenkins-docs/simple-java-maven-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
25 lines (20 loc) · 819 Bytes
/
Dockerfile
File metadata and controls
25 lines (20 loc) · 819 Bytes
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
# First stage: build environment
FROM maven:3.5.0-jdk-8-alpine AS builder
# To resolve dependencies first without re-download everytime
ADD ./pom.xml pom.xml
# By default mvn use '~/.m2' which could be cleaned up, change to use './.m2'
RUN mvn install -Dmaven.repo.local=./.m2
ADD ./src src/
# package jar
RUN mvn install -Dmaven.test.skip=true -Dmaven.repo.local=./.m2
# Second stage: runtime environment
From openjdk:15
# copy jar from the first stage
COPY --from=builder target/my-app-1.0-SNAPSHOT.jar my-app-1.0-SNAPSHOT.jar
# MY_CPU_LIMIT could be imported via downward API automatically in Kubernetes Deployment.
CMD ["java", \
"-XX:InitialRAMPercentage=75", \
"-XX:MaxRAMPercentage=75", \
"-XX:MinRAMPercentage=25", \
"-XX:ActiveProcessorCount=$MY_CPU_LIMIT", \
"-jar", "my-app-1.0-SNAPSHOT.jar"]