-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (25 loc) · 962 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
# To build and run:
#docker build -t chassis:openj9 .
#docker run --rm -p 8080:8080 --name chassis-openj9 -d chassis:openj9
ARG APP_NAME="blocking-microservice"
################ STAGE: BUILD ##################
FROM maven:3.8.1-adoptopenjdk-16-openj9 AS builder
ARG APP_NAME
WORKDIR /tmp/build/${APP_NAME}
COPY pom.xml ./
COPY src ./src
COPY db ./db
# '-Dbuild.name' defines the name of the jar file to be generated, as well as,
# the directory name under /var/log/ where the app logs will be saved
RUN mvn package "-Dbuild.name=${APP_NAME}"
################ STAGE: DEPLOY ##################
FROM adoptopenjdk:16-jre-openj9
ARG APP_NAME
WORKDIR /opt/app/blocking-microservice
RUN mkdir -p /var/log/blocking-microservice
EXPOSE 8080/tcp
COPY --from=builder /tmp/build/$APP_NAME/db db/
COPY --from=builder /tmp/build/$APP_NAME/target/${APP_NAME}.jar ./
RUN chmod -R 777 db/
ENV APP_JAR=${APP_NAME}.jar
ENTRYPOINT ["/bin/bash", "-c", "java -jar $APP_JAR"]