Do I need to put --mount-type=cache on every RUN or just the first?

118 Views Asked by At

Given I have a multistage Docker file for a gradle build with a dependencies layer a common build layer and layers for multiple executables.

If I do

RUN --mount=type=cache,target=/root/.gradle ./gradlew dependencies

in the dependencies layer, do I need to also do

RUN --mount=type=cache,target=/root/.gradle ./gradlew :com.foo.common:build

and

RUN --mount=type=cache,target=/root/.gradle ./gradlew  com.foo.bar:build

in the other layers or is just the first

--mount=type=cache,target=/root/.gradle

enough?

Every example I've found only has 1 RUN command, so I can't figure this out just from documentation

0

There are 0 best solutions below