From d5c6f31b5c149dd5ee264ea77a619ba91622a049 Mon Sep 17 00:00:00 2001 From: tautaus <43488851+tautaus@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:42:24 -0700 Subject: [PATCH] Add files via upload update for build --- Dockerfile | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2dbfce412..b67210092 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,26 @@ -# Use an official OpenJDK runtime as a parent image -FROM openjdk - -# Set the working directory inside the container -WORKDIR /app - -# Copy the Maven wrapper and the pom.xml file -COPY .mvn/ .mvn -COPY mvnw pom.xml ./ - -# Copy the project source code -COPY src ./src - -# Package the application -RUN ./mvnw clean package -DskipTests - -# Copy the JAR file to the app directory -COPY target/*.jar app.jar - -# Run the jar file -CMD ["java", "-jar", "app.jar"] - -# Expose the port the app runs on -EXPOSE 8080 +# First stage: Build the application using Maven +FROM maven:3.8.1-openjdk-17 AS build +WORKDIR /app + +# Copy the Maven wrapper and the pom.xml file +COPY .mvn/ .mvn +COPY mvnw pom.xml ./ + +# Copy the project source code +COPY src ./src + +# Package the application +RUN ./mvnw package + +# Second stage: Use an official OpenJDK runtime as a parent image +FROM openjdk +WORKDIR /app + +# Copy the JAR file from the build stage +COPY --from=build /app/target/*.jar app.jar + +# Run the jar file +CMD ["java", "-jar", "app.jar"] + +# Expose the port the app runs on +EXPOSE 8080