# Multi-stage build for Spring Boot backend FROM maven:3.9-eclipse-temurin-17-alpine AS build WORKDIR /app # Copy pom.xml and download dependencies (cached layer) COPY pom.xml . RUN mvn dependency:go-offline -B # Copy source code and build COPY src ./src RUN mvn clean package -DskipTests # Runtime stage FROM eclipse-temurin:17-jre-alpine WORKDIR /app # Copy JAR from build stage COPY --from=build /app/target/*.jar app.jar # Expose port EXPOSE 8080 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD wget --quiet --tries=1 --spider http://localhost:8080/api/actuator/health || exit 1 # Run the application ENTRYPOINT ["java", "-jar", "app.jar"]