Reputation: 4381
I have Go project. To cache modules I use COPY go.mod go.sum ./
. But my cache invalidates on Jenkins just one step before - on COPY project:
Step 5/16 : WORKDIR /go/src/github.com/project
---> Using cache
---> 5d2fce4711c2
Step 6/16 : RUN apt-get update && apt-get -y install libavutil-dev
---> Using cache
---> ab9414893097
Step 7/16 : COPY . /go/src/github.com/project
---> c7dc5b6a3c88 #
Step 8/16 : COPY go.mod go.sum ./
---> fbd7f900ed7a
At the same time locally it works like a charm.
Upvotes: 0
Views: 174
Reputation: 8421
The contents of .
which you are copying to /go/src/github.com/project
have changed, which is why the cache is invalidated.
.
is the build-context - the directory you are doing the docker build from. If anything changes in this folder, it will invalidate the cache.
If your source isn't changing and you want to preserve the cache, then move this copy above the previous one.
Upvotes: 1