From 17ffb6542d03afce432ea9bc582aed4b4723a7e1 Mon Sep 17 00:00:00 2001 From: mohitkumar1313 Date: Thu, 26 Sep 2024 18:58:59 -0400 Subject: [PATCH] adding dockerfile --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..5f26ed465 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Use an official OpenJDK 17 image as a base +FROM openjdk:17-jdk-slim + +# Set the working directory inside the container +WORKDIR /app + +# Copy the Maven wrapper files +COPY .mvn/ .mvn +COPY mvnw pom.xml ./ + +# Grant execution permission to Maven wrapper +RUN chmod +x ./mvnw + +# Download and install Maven dependencies (will be cached if unchanged) +RUN ./mvnw dependency:go-offline + +# Copy the remaining project files +COPY src ./src + +# Build the application using Maven wrapper +RUN ./mvnw clean package -DskipTests + +# Expose the port on which the application will run +EXPOSE 8080 + +# Run the Spring Boot application +ENTRYPOINT ["java", "-jar", "target/spring-petclinic-2.6.0-SNAPSHOT.jar"]