diff --git a/Dockerfile b/Dockerfile index f7cd959..baa7564 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,13 @@ -FROM openjdk:8 +# Stage 1: Build the application +FROM maven:3.8.4 AS build +WORKDIR /app +COPY pom.xml . +COPY src ./src +RUN mvn package -DskipTests + +# Stage 2: Package the application into a smaller image +FROM openjdk:8-jre-slim +WORKDIR /app +COPY --from=build /app/target/springboot-images-new.jar . EXPOSE 8080 -ADD target/springboot-images-new.jar springboot-images-new.jar -ENTRYPOINT ["java","-jar","/springboot-images-new.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "springboot-images-new.jar"]