Created
July 2, 2021 10:25
-
-
Save adam-sandor/9c87cc743392bfe5e778c4486a097154 to your computer and use it in GitHub Desktop.
Multistage Docker build with Maven
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM maven:3 AS build | |
WORKDIR /build | |
COPY pom.xml . | |
RUN mkdir -p src/main/java | |
COPY FakeMain.java src/main/java #without this mvn package will fail | |
RUN mvn package | |
COPY src ./src | |
RUN mvn package | |
FROM openjdk:10.0.1-10-jre | |
WORKDIR /app | |
COPY --from=build /build/target/myservice.jar . | |
CMD java -jar myservice.jar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment