-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
37 lines (24 loc) · 808 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
#Stage 1
# initialize build and set base image for first stage
FROM maven:3.8.4-jdk-11-slim as stage1
# speed up Maven JVM a bit
ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
# set working directory
WORKDIR /opt
# copy just pom.xml
COPY pom.xml .
# go-offline using the pom.xml
RUN mvn dependency:go-offline
# copy your other files
COPY ./src ./src
# compile the source code and package it in a jar file
RUN mvn clean install -Dmaven.test.skip=true
####-- Stage 2 --####
# set base image for second stage
FROM openjdk:19-jdk-alpine3.15
# set deployment directory
WORKDIR /opt
# copy over the built artifact from the maven image
COPY --from=stage1 /opt/target/spring-boot-mysql-0.0.1-SNAPSHOT.jar /opt
# Run the app
CMD ["java", "-jar","spring-boot-mysql-0.0.1-SNAPSHOT.jar"]