mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25:49 +00:00
Update Dockerfile
This commit is contained in:
parent
54992166d1
commit
26d5411092
1 changed files with 26 additions and 0 deletions
26
Dockerfile
26
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"]
|
||||
|
|
Loading…
Reference in a new issue