learnifymedhub commited on
Commit
742f2b9
·
verified ·
1 Parent(s): cb07837

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -5
Dockerfile CHANGED
@@ -1,11 +1,25 @@
1
- # Use official Eclipse Temurin for Java 21
2
- FROM eclipse-temurin:21-jdk-alpine AS build
3
  WORKDIR /app
4
- COPY . .
5
- RUN ./mvnw clean package -DskipTests
6
 
 
 
 
 
 
 
 
 
 
7
  FROM eclipse-temurin:21-jre-alpine
8
  WORKDIR /app
 
 
9
  COPY --from=build /app/target/*.jar app.jar
 
 
10
  EXPOSE 7860
11
- ENTRYPOINT ["java", "-jar", "app.jar"]
 
 
 
 
1
+ # Step 1: Build the jar using a full Maven image
2
+ FROM maven:3.9.6-eclipse-temurin-21 AS build
3
  WORKDIR /app
 
 
4
 
5
+ # Copy only the pom.xml first to cache dependencies (faster builds)
6
+ COPY pom.xml .
7
+ RUN mvn dependency:go-offline
8
+
9
+ # Copy the source code and build
10
+ COPY src src
11
+ RUN mvn clean package -DskipTests
12
+
13
+ # Step 2: Run the jar using a slim JRE image
14
  FROM eclipse-temurin:21-jre-alpine
15
  WORKDIR /app
16
+
17
+ # Copy the built jar from the previous stage
18
  COPY --from=build /app/target/*.jar app.jar
19
+
20
+ # Hugging Face specific setup
21
  EXPOSE 7860
22
+ # Set user to 1000 for Hugging Face permissions
23
+ USER 1000
24
+
25
+ ENTRYPOINT ["java", "-jar", "app.jar", "--server.port=7860"]