Open sarahcthekey opened 1 year ago
Please provide a runnable reproducer for this case. I couldn't reproduce similar case locally:
FROM alpine
RUN apk add git
ARG GIT_HASH
RUN env > snapshot
docker buildx create --name=issue4084 --bootstrap
export BUILDX_BUILDER=issue4084
docker buildx build --cache-to type=local,dest=../cache .
# fully cached
docker buildx prune -a
docker buildx build --cache-from type=local,src=../cache .
# last step not cached
docker buildx prune -a
docker buildx build --cache-from type=local,src=../cache --build-arg GIT_HASH=foo .
=> CACHED [2/3] RUN apk add git 0.3s
=> => sha256:8c6d1654570f041603f4cef49c320c8f6f3e401324913009d92a19132cbf1ac0 3.33MB / 3.33MB 0.0s
=> => extracting sha256:8c6d1654570f041603f4cef49c320c8f6f3e401324913009d92a19132cbf1ac0 0.1s
=> => sha256:afa2557f73df36a5cce15e5b68a35d5db4d469a75e1c3a8927167abafef02786 7.14MB / 7.14MB 0.1s
=> => extracting sha256:afa2557f73df36a5cce15e5b68a35d5db4d469a75e1c3a8927167abafef02786 0.1s
=> [3/3] RUN env > snapshot 0.1s
We have a workflow which includes the following step to build and push our image - docker/build-push-action@v3:
In the Dockerfile we install a few private python packages, here's a shortened version of our Dockerfile showing relevant bits:
We use
ARG GIT_HASH
which will change on each github branch build, this has been added to trigger a cache miss when installing the python packages immediately after as per the official docs -If a layer changes, all other layers that come after it are also affected. When the layer with the ARG GIT_HASH command gets invalidated, all layers that follow will need to run again, too
, to ensure a fresh up to date copy of the packages are installed rather than use the cache.However this doesn't appear to be working and the image is still being built using older versions of the packages.
It only works if I completely comment out the
cache-from
andcache-to
lines to stop using the github actions cache.Snippet from Docker build log on github actions:
Any ideas why this could be?