forked from spring-projects/spring-petclinic
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathDockerfile
39 lines (27 loc) · 1000 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
37
38
39
### Multi-stage Docker file - maven build for java ###
## Stage 1/2 - Build fat JAR file with maven
FROM maven:3-jdk-8-slim as builder
RUN mkdir -p /build
WORKDIR /build
COPY pom.xml /build
# download all required dependencies into a single layer that won't change unless there's a change in pom.xml
RUN mvn dependency:go-offline -B
# RUN mvn -B dependency:resolve dependency:resolve-plugins
#Copy source code
COPY src /build/src
# Build application
RUN mvn package -DAPP_VERSION=v1.0 -DskipTests
## Stage 2/2 - Containerize the standalone JAR application
FROM susesamples/sles15sp1-openjdk11:11.0.7 as runtime
EXPOSE 8080
ENV APP_HOME /app
ENV JAVA_OPTS=""
RUN mkdir $APP_HOME
# store externalized config files and logs
RUN mkdir $APP_HOME/config
RUN mkdir $APP_HOME/log
VOLUME $APP_HOME/config
VOLUME $APP_HOME/log
WORKDIR $APP_HOME
COPY --from=builder /build/target/*.jar app.jar
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar app.jar $0 $@" ]