spring-petclinic/Dockerfile

26 lines
614 B
Docker
Raw Normal View History

2025-01-29 11:48:56 +00:00
# Stage 1: Build Stage
FROM maven:3.9.4-eclipse-temurin-17 AS build
# Set the working directory inside the build stage
WORKDIR /app
# Copy the Maven project files to the build stage
COPY pom.xml .
COPY src ./src
# Build the project and create the jar
RUN mvn clean package -DskipTests
# Stage 2: Runtime Stage
FROM openjdk:17-alpine
# Set the working directory inside the runtime stage
WORKDIR /app
# Copy the built jar from the build stage
COPY --from=build /app/target/spring-petclinic-4.0.2-SNAPSHOT.jar /app/
# Command to run the application
CMD ["java", "-jar", "spring-petclinic-4.0.2-SNAPSHOT.jar"]