dotnet / dotnet/docker-tools

Image caching support for copied local files

Open
#1,270 2 comments 0 reactions 0 assignees View on GitHub
area-infrastructure enhancement
Dominant language
C#
Stars
181
Forks
67
Avg merge
2d 15h
Merged PRs (30d)
10

Description

Image Builder's image caching support has the ability to determine that a Dockerfile should be rebuilt if its checksum has changed since it was last published. This checksum comparison is strictly limited to the Dockerfile, however. It doesn't handle cases where the Dockerfile is configured to copy in local files that are operated upon. Any change to those files (and not the Dockerfile) wouldn't trigger the Dockerfile to be rebuilt. There are such cases of Dockerfiles copying in local files in the buildtools-prereqs repo ([example](https://github.com/dotnet/dotnet-buildtools-prereqs-docker/blob/591ee26a262ebc729c9a3d981b00bbf0bb86a908/src/ubuntu/22.04/helix/webassembly/Dockerfile#L40)).

Image Builder should be updated to account for such file changes so that the Dockerfile can be rebuilt.

I see two options to support this:
* Update the existing image caching implementation to support other arbitrary files beyond the Dockerfile. This could be hard to maintain because the checksums for those would need to be stored in the image info JSON file which means Image Builder needs to know which files to track. So we'd either need to statically list those files the Dockerfile depends on in the manifest or something OR Image Builder would have to dynamically derive those files by parsing the Dockerfile. Rather than parsing the Dockerfile to see what gets copied, we could have Image Builder just scan the directory (recursively) where the Dockerfile is located and track all those files.
* Make use of the Docker BuildKit's caching feature ([`--cache-from`](https://docs.docker.com/reference/cli/docker/buildx/build/#cache-from), [`--cache-to`](https://docs.docker.com/reference/cli/docker/buildx/build/#cache-to)). BuildKit isn't yet supported for Windows in current versions of Docker though.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.