I have a Java(Gradle) project. A docker image is built in CI using Dockerfile:
FROM gradle:6.8.3-jdk11
COPY --chown=gradle:gradle . /home/gradle/app
WORKDIR /home/gradle/app
RUN gradle compileTestJava
Although gradle compileTestJava
downloads all dependencies, when the container is run from the image, gradle cache turns out to be empty and all dependencies are being redownloaded.
How can I make gradle cache attached to the image so it would be used in containers?