-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (26 loc) · 888 Bytes
/
Dockerfile
File metadata and controls
38 lines (26 loc) · 888 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
28
29
30
31
32
33
34
35
36
37
38
# Stage 1: Build the Spring Boot application
FROM maven:3.9-eclipse-temurin-17 AS build
# Set the working directory in the build stage
WORKDIR /app
# Copy the Maven wrapper files
COPY .mvn/ .mvn
# Copy the Maven wrapper and pom.xml
COPY mvnw pom.xml ./
# Give execute permission to the Maven wrapper script
RUN chmod +x ./mvnw
# Download dependencies and cache them
RUN ./mvnw dependency:go-offline -q
# Copy the source code
COPY src ./src
# Build the application, skipping tests to reduce build time
RUN ./mvnw clean package -DskipTests -q
# Stage 2: Create the final Docker image
FROM openjdk:17-jdk-alpine
# Set the working directory in the final image
WORKDIR /app
# Copy the built JAR file from the build stage
COPY --from=build /app/target/*.jar app.jar
# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]
# Set the default port for the application
EXPOSE 8082