-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Dockerfile
32 lines (23 loc) · 841 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
# Base image with Java 17 (using a lightweight Alpine variant for efficiency)
FROM eclipse-temurin:22-jdk-alpine as builder
# Set working directory
WORKDIR /workspace/app
# Copy Maven dependencies (for efficient caching and layer separation)
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
RUN ./mvnw dependency:go-offline -B
# Copy project source code
COPY src src
# Build the application with Maven
RUN ./mvnw package -DskipTests
# Create a lightweight runtime image
FROM eclipse-temurin:22-jdk-alpine
# Set working directory
WORKDIR /app
# Copy the built JAR file from the builder stage
COPY --from=builder /workspace/app/target/*.jar /app/app.jar
# Expose the application port (replace with your actual port if different)
EXPOSE 8080
# Run the application using Spring Boot's executable JAR
ENTRYPOINT ["java", "-jar", "/app/app.jar"]