# Use the official Maven image for building the application FROM maven:3.9.6-eclipse-temurin-17 AS build WORKDIR /app # Copy the full source code COPY . . # Build the application - produces a target/*.jar RUN mvn clean package -DskipTests # Use a minimal Java runtime for running the app FROM eclipse-temurin:17-jre RUN useradd -m -u 1000 user USER user WORKDIR /home/user/app # Copy the jar from the builder stage COPY --from=build /app/target/*.jar ./app.jar # The app must listen on port 7860 for Hugging Face Spaces ENV PORT=7860 EXPOSE 7860 # Optionally, pass --server.port=7860 to Spring Boot CMD ["java", "-jar", "app.jar", "--server.port=7860"]