Skip to content

Instantly share code, notes, and snippets.

@nieldw
Created March 7, 2019 15:14
Show Gist options
  • Save nieldw/6033d52b5686f05053db0d0b56ddfefc to your computer and use it in GitHub Desktop.
Save nieldw/6033d52b5686f05053db0d0b56ddfefc to your computer and use it in GitHub Desktop.
Caching gradle binaries in a docker build when using the gradle wrapper
# Stage 1, build container
ARG VERSION=8u181
FROM openjdk:${VERSION}-jdk-slim as BUILD
# Get gradle distribution
COPY *.gradle gradle.* gradlew /src/
COPY gradle /src/gradle
WORKDIR /src
RUN ./gradlew --version
COPY . .
ENV MAIN_CLASS_NAME=com.example.App
RUN ./gradlew --no-daemon shadowJar
# Stage 2, distribution container
FROM openjdk:${VERSION}-jre-slim
COPY --from=BUILD /src/build/libs/app-all.jar /bin/run.jar
CMD ["java", "-d64", "-jar", "/bin/run.jar"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment