Open FernandoMiguel opened 6 years ago
Are you saying that a base image in a dockerfile changed but the change was only in labels metadata and all the layers were still the same? Or that you expect every command (eg. RUN) to do content-based caching same way as COPY
does.
The base images only changed metadata between consecutive builds as everything else in its rebuild was cached. So far so good.
The issue is with the dependant images. From their point of view the base image is new (which is true) but the actual change for both base and child images was just metadata, all the source code is the same. But since the child sees a new build id for the base image, and the first layer is a newish FROM, all further cache is being invalidated.
I am seeking a better support in dealing with these scenarios, so that Docker/buildkit will avoid the cache invalidation if the base image significant layers are the same
Hope that makes sense.
bumping this, is there interest short term or long term to address this or shall i look at alternatives?
Sorry for inactivity on this.
One of the cache keys for an image source(at least in schema2 when this is possible) is the checksum of the layers. So if the only thing that changed in the base image was metadata it should not invalidate the next commands (except for example env cause they would change the runtime context of the subsequent RUN commands).
If you think this is not the case please post an example we could try. For example, 2 public images that show this.
Thanks for looking into this again. I'm away this week, but I'll try to provide an example as soon as possible
Cheers
We have a use case where a dependentant image gets its cache invalidated by the upstream image adding a new label.
We are wondering if there is anything that can be done at buildkit level (since there is so much work done to improve caching) that could help us improve this use case.
We first build a php docker (using docker-compose)
docker-compose tags the labels.
We then build images that use that as the FROM image
Here's the bit from docker-compose
Sadly even with no code change in any of these two code bases, if anything changes in the repo, the HEAD will change, making the label be updated. What happens is that the dependant image will now bust cache cause the upstream image updated the label, and as such the image id.