Skip to content
Snippets Groups Projects
Commit 85355c32 authored by Andreas's avatar Andreas
Browse files

refactor/Updated Dockerfile

parent 641a196a
No related branches found
No related tags found
1 merge request!85Feat/workflow implement docker push and deploy
Pipeline #283529 passed
FROM maven:3-jdk-8-alpine as builder # Step 1: Build the application
FROM maven:3.8.5-openjdk-17 AS build
WORKDIR /usr/src/app # Set the working directory in the container
WORKDIR /app
COPY . /usr/src/app # Copy the Maven pom.xml and source code into the container
RUN mvn package COPY pom.xml .
COPY src ./src
FROM openjdk:8-jre-alpine # Compile and package the application to an executable JAR
RUN mvn clean package -DskipTests
COPY --from=builder /usr/src/app/target/*.jar /app.jar # Step 2: Run the application
FROM openjdk:17-slim
# Set the deployment directory
WORKDIR /app
# Copy the JAR from the build stage to the run stage
COPY --from=build /app/target/*.jar app.jar
# Expose the port the app runs on
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT ["java"] # Run the application
CMD ["-jar", "/app.jar"] CMD ["java", "-jar", "app.jar"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment