Skip to content

Instantly share code, notes, and snippets.

@durimkryeziu
Last active November 30, 2019 19:19
Show Gist options
  • Save durimkryeziu/8f5cfb87577b5b997b57bf3a5b0a385a to your computer and use it in GitHub Desktop.
Save durimkryeziu/8f5cfb87577b5b997b57bf3a5b0a385a to your computer and use it in GitHub Desktop.
Spring Boot Docker | Gradle | Multi-Stage Build
# Gradle version of this: https://spring.io/guides/topicals/spring-boot-docker/#_multi_stage_build
FROM azul/zulu-openjdk-alpine:11.0.5 as build
WORKDIR /workspace/app/
COPY gradlew .
COPY gradle gradle
COPY build.gradle settings.gradle /workspace/app/
COPY src src
ENV GRADLE_OPTS -Dorg.gradle.daemon=false -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false
RUN ./gradlew build
RUN mkdir -p build/dependency && (cd build/dependency; jar -xf ../libs/*.jar)
FROM azul/zulu-openjdk-alpine:11.0.5-jre
VOLUME /tmp
ENV DEPENDENCY=/workspace/app/build/dependency
COPY --from=build $DEPENDENCY/BOOT-INF/lib /app/lib
COPY --from=build $DEPENDENCY/META-INF /app/META-INF
COPY --from=build $DEPENDENCY/BOOT-INF/classes /app
EXPOSE 8080
ENTRYPOINT ["java", "-cp", "app:app/lib/*", "com.programmingskillz.Application"]
@durimkryeziu
Copy link
Author

For more details, read this article: https://spring.io/guides/topicals/spring-boot-docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment