From 26d5411092da0b8049bc7c3ed8954476a94bd076 Mon Sep 17 00:00:00 2001 From: MihailInternul <157023284+MihailInternul@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:17:17 +0200 Subject: [PATCH] Update Dockerfile --- Dockerfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8b1378917..b84a1205d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,27 @@ +# Use a base image with Java and Maven installed +FROM maven:3.8.4-openjdk-17-slim AS builder +# Set the working directory in the container +WORKDIR /app + +# Copy the Maven project files +COPY pom.xml . +COPY src ./src + +# Build the application +RUN mvn clean package -DskipTests + +# Use a lightweight base image for the application +FROM openjdk:17-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the compiled application from the builder stage +COPY --from=builder /app/target/spring-petclinic*.jar ./app.jar + +# Expose the port on which the application will run +EXPOSE 8080 + +# Define the command to run the application when the container starts +CMD ["java", "-jar", "app.jar"]