Trying to get the multi-stage Spring Boot application Dockerfile that works.
The idea is to:
- Build and package the project using
- Run the built .jar file
After some research, I found this article. It provides complete Dockerfile, but it does not work for me.
I modified the initial Dockerfile, and now it looks like this:
FROM maven:3.6.2-jdk-8-slim AS MAVEN_BUILD COPY pom.xml /build/ COPY src /build/src/ WORKDIR /build/ RUN mvn -Dmaven.test.skip=true package -Ptest # This line does not work properly FROM openjdk:8-jre WORKDIR /app COPY --from=MAVEN_BUILD /build/target/platform-0.0.1.jar /app/ ENTRYPOINT ["java", "-jar", "platform-0.0.1.jar"]
I created a
docker-compose.yml that tries to build this Dockerfile:
[...] api: build: context: . dockerfile: Dockerfile depends_on: - mysql-db ports: - "8080:8085" [...]
Am I missing something?
mvn -Dmaven.test.skip=true package -Ptest command in the actual project folder works normally…