dotnet / docker-tools

This is a repo to house some common tools for our various docker repos.
MIT License
125 stars 47 forks source link

Image caching doesn't account for build args #1505

Closed mthalman closed 19 hours ago

mthalman commented 3 days ago

Image Builder's image caching logic doesn't account for a Dockerfile having ARG instructions defined which may vary across builds. This can lead to cache hits when a cache miss should occur, which would mean not re-building an image when it should be. This can occur in the following scenario:

  1. Dockerfile commit is the same as the previously published image
  2. Base image digest is the same as the previously published image
  3. The ARG value is different than the value that was used for the previously published image

In order to fix this, it would be necessary to store the ARG values in the image info file that gets stored in https://github.com/dotnet/versions/tree/main/build-info/docker. Then the logic could retrieve those values and compare them to the current value to see whether they're the same or different.

There are currently no practical examples of this issue. All of the usages of ARG amongst our Dockerfiles are essentially statically defined with no intent to change them. However, it may become relevant based on any improvements we decide to make in https://github.com/dotnet/dotnet-buildtools-prereqs-docker to improve maintainability, such as https://github.com/dotnet/dotnet-buildtools-prereqs-docker/issues/1267.

dotnet-issue-labeler[bot] commented 3 days ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 3 days ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

lbussell commented 19 hours ago

[Triage] Closing as not planned since there isn't currently an issue with this behavior. We should re-open if we decide to use ARGS to accomplish https://github.com/dotnet/dotnet-buildtools-prereqs-docker/issues/1267.