19 lines
603 B
Docker
19 lines
603 B
Docker
|
|
# Build stage: uses Maven + JDK 17 (Alpine) to compile and package the application.
|
||
|
|
FROM maven:3.9-eclipse-temurin-17-alpine AS builder
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy pom.xml first to leverage Docker layer caching for dependency downloads.
|
||
|
|
COPY pom.xml .
|
||
|
|
RUN mvn dependency:go-offline -q
|
||
|
|
|
||
|
|
# Copy source and build the fat JAR, skipping tests.
|
||
|
|
COPY src ./src
|
||
|
|
RUN mvn clean package -DskipTests -q
|
||
|
|
|
||
|
|
# Runtime stage: slim JRE-only image for a smaller production footprint.
|
||
|
|
FROM eclipse-temurin:17-jre-alpine
|
||
|
|
WORKDIR /app
|
||
|
|
COPY --from=builder /app/target/*.jar app.jar
|
||
|
|
EXPOSE 8080
|
||
|
|
ENTRYPOINT ["java", "-jar", "app.jar"]
|