KevanSoon commited on
Commit
68aeff7
·
1 Parent(s): 437b610

changed dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -8
Dockerfile CHANGED
@@ -2,10 +2,10 @@ FROM eclipse-temurin:17-jdk AS build
2
 
3
  WORKDIR /app
4
 
5
- # Install Maven just for dependency fetching
6
- RUN apt-get update && apt-get install -y maven curl && rm -rf /var/lib/apt/lists/*
7
 
8
- # Create a minimal pom.xml to fetch Javalin + Gson
9
  RUN echo '<project xmlns="http://maven.apache.org/POM/4.0.0" \
10
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
11
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 \
@@ -20,20 +20,19 @@ RUN echo '<project xmlns="http://maven.apache.org/POM/4.0.0" \
20
  </dependencies> \
21
  </project>' > pom.xml
22
 
23
- # Download dependencies into /root/.m2/repository
24
  RUN mvn dependency:copy-dependencies -DoutputDirectory=libs
25
 
26
- # Copy source
27
  COPY DemoApplication.java User.java ./
28
 
29
- # Compile with all dependencies
30
- RUN javac -cp "libs/*" DemoApplication.java User.java && \
31
  jar cfe app.jar DemoApplication *.class
32
 
33
  FROM eclipse-temurin:17-jre
34
  WORKDIR /app
35
 
36
- # Copy compiled JAR + libraries
37
  COPY --from=build /app/app.jar .
38
  COPY --from=build /app/libs ./libs
39
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Install Maven for dependency fetching
6
+ RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
7
 
8
+ # Create minimal pom.xml
9
  RUN echo '<project xmlns="http://maven.apache.org/POM/4.0.0" \
10
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
11
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 \
 
20
  </dependencies> \
21
  </project>' > pom.xml
22
 
23
+ # Download dependencies into libs/
24
  RUN mvn dependency:copy-dependencies -DoutputDirectory=libs
25
 
26
+ # Copy sources
27
  COPY DemoApplication.java User.java ./
28
 
29
+ # Compile including libs and current dir
30
+ RUN javac -cp "libs/*:." DemoApplication.java User.java && \
31
  jar cfe app.jar DemoApplication *.class
32
 
33
  FROM eclipse-temurin:17-jre
34
  WORKDIR /app
35
 
 
36
  COPY --from=build /app/app.jar .
37
  COPY --from=build /app/libs ./libs
38