I have the following Dockerfile
FROM gradle:jdk13 AS appbuild
WORKDIR "/home/gradle/"
COPY --chown=gradle:gradle "./build.gradle" "/home/gradle/"
RUN gradle dependencies
COPY --chown=gradle:gradle "./src/" "/home/gradle/src/"
RUN gradle build --info
FROM openjdk:13
ENV LANG en_US.UTF-8
COPY --from=appbuild "/home/gradle/build/libs/frontend.jar" "/frontend.jar"
CMD ["java", "-jar", "-Dspring.profiles.active=default", "/frontend.jar"]
My aim is to prevent gradle from downloading the dependencies every time I build a docker image.
The command gradle dependencies
downloads all the required java libraries in case they are missing.
Before the first gradle dependencies
command I only copied the build.gradle in order to only download the dependencies and cache them.
When I run the gradle build
command, why does it want to download all the files again? They are already present in one of the layers.
I have tried with RUN gradle clean build --info || return 0
instead of gradle dependencies
, all the same.