forked from Sonal0409/DevOpsCodeDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
26 lines (18 loc) · 664 Bytes
/
Copy pathdockerfile
File metadata and controls
26 lines (18 loc) · 664 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
# Use the Maven base image with JDK
FROM maven:3.8-jdk-11 AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the entire project into the container
COPY . .
# Run Maven to build the project
RUN mvn clean package
# Create a new stage for the final application image
FROM openjdk:11-jre
# Set the working directory for the new stage
WORKDIR /app
# Copy the built artifact (e.g., JAR, WAR) from the builder stage to the final stage
COPY --from=builder /app/target/*.war .
# Expose the desired port for the application
EXPOSE 8080
# Set the command to run your application (adjust if needed)
CMD ["java", "-jar", "addressbook.war"]