Spaces:
No application file
No application file
| # Multi-stage build for optimized image size | |
| # Stage 1: Build the application | |
| FROM maven:3.9-openjdk-17 AS builder | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy Maven files | |
| COPY pom.xml . | |
| COPY src ./src | |
| # Build the application | |
| RUN mvn clean package -DskipTests | |
| # Stage 2: Run the application | |
| FROM openjdk:17-jdk-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy the JAR from builder stage | |
| COPY --from=builder /app/target/*.jar app.jar | |
| # Expose the port that Hugging Face expects (7860) | |
| EXPOSE 7860 | |
| # Set the user to non-root for security | |
| RUN useradd -m -u 1000 user && chown -R user:user /app | |
| USER user | |
| # Run the Spring Boot application | |
| ENTRYPOINT ["java", "-jar", "/app/app.jar"] | |