# -------- Stage 1: Build the Spring Boot application -------- FROM maven:3.9.6-eclipse-temurin-21 AS build # Create a working directory WORKDIR /app # Copy the Maven project files COPY pom.xml . COPY src ./src # Build the project (skip tests to speed up) RUN mvn clean package -DskipTests # -------- Stage 2: Create a lightweight runtime image -------- FROM openjdk:21-jdk # Set working directory in runtime container WORKDIR /app # Copy the built jar file from the build stage COPY --from=build /app/target/*.jar app.jar # Expose the Spring Boot default port EXPOSE 7860 # Run the app ENTRYPOINT ["java", "-jar", "app.jar"]