Last active
January 4, 2022 23:27
-
-
Save sairamkrish/05ad4ba04c4096b26d3526579c970ab4 to your computer and use it in GitHub Desktop.
Dockerfile for gradle, spring boot application using multi-stage feature
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:8 AS TEMP_BUILD_IMAGE | |
ENV APP_HOME=/usr/app/ | |
WORKDIR $APP_HOME | |
COPY build.gradle settings.gradle gradlew $APP_HOME | |
COPY gradle $APP_HOME/gradle | |
RUN ./gradlew build || return 0 | |
COPY . . | |
RUN ./gradlew build | |
FROM openjdk:8 | |
ENV ARTIFACT_NAME=your-application.jar | |
ENV APP_HOME=/usr/app/ | |
WORKDIR $APP_HOME | |
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME . | |
EXPOSE 8080 | |
CMD ["java","-jar",$ARTIFACT_NAME] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment