Dockerfile 787 B

123456789101112131415161718192021222324
  1. # Use an official Maven image as the base image
  2. FROM maven:3.8.5-openjdk-17 AS build
  3. # Set the working directory in the container
  4. WORKDIR /app
  5. # Copy the pom.xml and the project files to the container
  6. ADD ./pom.xml pom.xml
  7. ADD settings.xml /usr/share/maven/conf/settings.xml
  8. RUN mvn dependency:go-offline
  9. COPY src /app/src
  10. # Build the application using Maven
  11. RUN mvn clean package -DskipTests
  12. # Use an official OpenJDK image as the base image
  13. FROM openjdk:17-jdk-slim
  14. # Set the working directory in the container
  15. WORKDIR /app
  16. # Copy the built JAR file from the previous stage to the container
  17. COPY --from=build /app/target/*.jar ./app.jar
  18. # Set the command to run the application
  19. CMD ["java", "-jar", "/app/app.jar","--spring.config.location=file:/app/application.yaml"]
  20. EXPOSE 8080