-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
27 lines (19 loc) · 703 Bytes
/
Dockerfile
File metadata and controls
27 lines (19 loc) · 703 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
26
27
# Use a base image that includes both OpenJDK and Maven
FROM maven:3.8.2-openjdk-17 AS build
# Set the working directory in the Docker image
WORKDIR /app
# Copy the pom.xml file into the Docker image
COPY pom.xml .
# Copy the source code into the Docker image
COPY src ./src
RUN mvn clean
# Run mvn install to build the jar file
RUN mvn install
# Use a base image that includes just OpenJDK for the runtime image
FROM openjdk:17-jdk-alpine AS runtime
# Set the working directory in the Docker image
WORKDIR /app
# Copy the jar file from the build image to the runtime image
COPY --from=build /app/target/*.jar app.jar
# Set the startup command to execute the jar
CMD ["java", "-jar", "app.jar"]