Last active
January 28, 2022 02:24
-
-
Save vvillschneider/44a32984bf922c88b2dc38f305b007f8 to your computer and use it in GitHub Desktop.
Multi-step Dockerfile for Java project with Gradle
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 openjdk:17-oracle AS BUILD_IMAGE | |
ENV BASE_DIRECTORY=/app/ | |
WORKDIR $BASE_DIRECTORY | |
COPY build.gradle settings.gradle gradlew $BASE_DIRECTORY | |
COPY gradle $BASE_DIRECTORY/gradle | |
RUN ./gradlew build --stacktrace || return 0 | |
COPY src $BASE_DIRECTORY/src | |
RUN ./gradlew build --stacktrace | |
FROM openjdk:17-oracle | |
ENV BASE_DIRECTORY=/app/ | |
WORKDIR $BASE_DIRECTORY | |
COPY --from=BUILD_IMAGE $BASE_DIRECTORY/build/libs/main-service.jar . | |
EXPOSE 8080 | |
ENTRYPOINT ["java","-jar","main-service.jar"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment