adding dockerfile

This commit is contained in:
mohitkumar1313 2024-09-26 18:58:59 -04:00
parent 2daa3993ee
commit 17ffb6542d

27
Dockerfile Normal file
View file

@ -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"]