File size: 1,209 Bytes
18b0cd1
153db70
177c18c
 
 
7d73ac4
 
177c18c
742f2b9
153db70
742f2b9
177c18c
742f2b9
 
 
177c18c
 
153db70
7d73ac4
742f2b9
177c18c
7d73ac4
742f2b9
177c18c
7d73ac4
742f2b9
 
177c18c
 
e5486e1
153db70
e5486e1
 
 
 
 
153db70
e5486e1
153db70
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# /* File Path: /Dockerfile */

# Stage 1: Build stage
# Using '3-eclipse-temurin-25' ensures we get the latest Maven 3 with Java 25
FROM maven:3-eclipse-temurin-25 AS build
WORKDIR /app

# Cache dependencies
COPY pom.xml .
RUN mvn dependency:go-offline -B

# Build the app
COPY src src
RUN mvn clean package -DskipTests

# Stage 2: Runtime stage
# We use the '25-jre-alpine' for the smallest, most secure production footprint
FROM eclipse-temurin:25-jre-alpine
WORKDIR /app

# Copy the built jar from the build stage
COPY --from=build /app/target/*.jar app.jar

# Hugging Face specific setup
EXPOSE 7860
USER 1000

# Performance: Enable Virtual Threads for high concurrency on your 2 vCPUs
# Performance: Use MaxRAMPercentage to let the JVM manage the 16GB RAM dynamically
# Updated Entrypoint for 16GB RAM / 2 vCPU
ENTRYPOINT ["java", \
            "-XX:+UseG1GC", \
            "-XX:MaxGCPauseMillis=200", \
            "-XX:ParallelGCThreads=2", \
            "-XX:ConcGCThreads=1", \
            "-XX:InitiatingHeapOccupancyPercent=45", \
            "-XX:MaxRAMPercentage=75.0", \
            "-Dspring.threads.virtual.enabled=true", \
            "-jar", "app.jar", \
            "--server.port=7860"]