Spaces:
Sleeping
Sleeping
KevanSoon
commited on
Commit
·
872e5c6
1
Parent(s):
5b8cc33
adjsuted dockerfile
Browse files- Dockerfile +15 -3
Dockerfile
CHANGED
|
@@ -1,15 +1,27 @@
|
|
| 1 |
# Stage 1: Build the application with Maven
|
| 2 |
FROM maven:3.9.5-eclipse-temurin-17 AS build
|
| 3 |
WORKDIR /app
|
|
|
|
|
|
|
| 4 |
COPY pom.xml .
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
RUN mvn clean package
|
| 7 |
|
| 8 |
# Stage 2: Create a lightweight runtime image
|
| 9 |
FROM eclipse-temurin:17-jre-alpine
|
| 10 |
WORKDIR /app
|
|
|
|
|
|
|
| 11 |
COPY --from=build /app/target/app.jar /app/app.jar
|
| 12 |
-
|
|
|
|
| 13 |
EXPOSE 7860
|
| 14 |
-
|
|
|
|
| 15 |
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
|
|
|
|
| 1 |
# Stage 1: Build the application with Maven
|
| 2 |
FROM maven:3.9.5-eclipse-temurin-17 AS build
|
| 3 |
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Copy the pom.xml from the root of your project. This is correct.
|
| 6 |
COPY pom.xml .
|
| 7 |
+
|
| 8 |
+
# --- THIS IS THE CORRECTED LINE ---
|
| 9 |
+
# Copy the source code from the 'demo/src' directory on your host
|
| 10 |
+
# to the 'src' directory inside the container.
|
| 11 |
+
COPY demo/src ./src
|
| 12 |
+
|
| 13 |
+
# Run the Maven package command. Maven will now find pom.xml and the src folder.
|
| 14 |
RUN mvn clean package
|
| 15 |
|
| 16 |
# Stage 2: Create a lightweight runtime image
|
| 17 |
FROM eclipse-temurin:17-jre-alpine
|
| 18 |
WORKDIR /app
|
| 19 |
+
|
| 20 |
+
# Copy the built JAR from the 'build' stage
|
| 21 |
COPY --from=build /app/target/app.jar /app/app.jar
|
| 22 |
+
|
| 23 |
+
# Expose the port the application will run on.
|
| 24 |
EXPOSE 7860
|
| 25 |
+
|
| 26 |
+
# Command to run the application
|
| 27 |
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
|