mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
Add files via upload
update for build
This commit is contained in:
parent
a3c15027d5
commit
d5c6f31b5c
1 changed files with 26 additions and 24 deletions
16
Dockerfile
16
Dockerfile
|
@ -1,7 +1,5 @@
|
||||||
# Use an official OpenJDK runtime as a parent image
|
# First stage: Build the application using Maven
|
||||||
FROM openjdk
|
FROM maven:3.8.1-openjdk-17 AS build
|
||||||
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the Maven wrapper and the pom.xml file
|
# Copy the Maven wrapper and the pom.xml file
|
||||||
|
@ -12,10 +10,14 @@ COPY mvnw pom.xml ./
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
|
|
||||||
# Package the application
|
# Package the application
|
||||||
RUN ./mvnw clean package -DskipTests
|
RUN ./mvnw package
|
||||||
|
|
||||||
# Copy the JAR file to the app directory
|
# Second stage: Use an official OpenJDK runtime as a parent image
|
||||||
COPY target/*.jar app.jar
|
FROM openjdk
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the JAR file from the build stage
|
||||||
|
COPY --from=build /app/target/*.jar app.jar
|
||||||
|
|
||||||
# Run the jar file
|
# Run the jar file
|
||||||
CMD ["java", "-jar", "app.jar"]
|
CMD ["java", "-jar", "app.jar"]
|
||||||
|
|
Loading…
Reference in a new issue