Created
October 16, 2021 03:50
-
-
Save paill/d7c497213f03f59818f796d33174ab43 to your computer and use it in GitHub Desktop.
Build & run Java app using multi-stage Dockerfile
This file contains hidden or 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
docker build -t myjavaappimage . | |
docker run --rm --name myjavaappcontainer -v "$(pwd)":/tmp/run myjavaappimage |
This file contains hidden or 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-openjdk-8 AS builder | |
COPY src /tmp/src | |
RUN mvn -f /tmp/src clean package -DskipTests | |
FROM openjdk: | |
COPY --from=builder /tmp/src/target/myjar-0.0.1-SNAPSHOT.jar /tmp/run/myjar.jar | |
WORKDIR /tmp/run | |
CMD ["java","-jar","myjar.jar"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment