Update Dockerfile

This commit is contained in:
MihailInternul 2024-02-15 15:17:17 +02:00 committed by GitHub
parent 54992166d1
commit 26d5411092
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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