<#799 feat: respect .dockerignore in image cache ...
# flyte-github
a
#799 feat: respect .dockerignore in image cache key computation Pull request opened by AdilFayyaz Motivation CopyConfig and UVProject were hashing all files in a directory regardless of .dockerignore, so changes to excluded files (e.g. build artifacts, data files) incorrectly invalidated the image cache. Additionally, DockerIgnore.update_hash was hashing the file path instead of its content, so editing .dockerignore had no effect on the cache key. Summary • Fixed DockerIgnore.update_hash to hash file content instead of the path string • Added DockerfileIgnore(Ignore) to _code_bundle/_ignore.py — wraps PatternMatcher (the same matcher used by the actual Docker build context) and fits into the existing Ignore/IgnoreGroup hierarchy • Refactored update_hasher_for_source to accept ignore: _IgnoreLike (Protocol) instead of a raw Callable, adds directory pruning, and passes absolute paths consistent with list_all_files • Image._get_hash_digest() now resolves the dockerignore once (last DockerIgnore layer wins, falls back to root_dir/.dockerignore from init config) and threads it through all layer.update_hash(hasher, ignore=ignore) calls — so .dockerignore at the project root is correctly applied even when src is a subdirectory Test Plan • uv run pytest tests/flyte/test_image.py -v — includes 7 new tests: • test_dockerignore_hash_changes_with_content: changing .dockerignore content produces a different hash • test_dockerignore_hash_stable_for_same_content: same content produces a stable hash • test_image_uri_changes_when_dockerignore_content_changes: image URI (cache key) changes when .dockerignore changes • test_copy_config_update_hash_respects_dockerignore: files matched by .dockerignore are excluded from the CopyConfig hash • test_copy_config_dockerignore_itself_is_hashed: changing .dockerignore content changes the CopyConfig hash • test_uv_project_install_project_respects_dockerignore: same coverage for UVProject install_project mode • test_copy_config_respects_dockerignore_from_image_layer — .dockerignore at project root (via with_dockerignore()) is applied to CopyConfig even when src is a subdirectory • uv run pytest tests/flyte/code_bundle/test_ignore.py -v — regression check on the Ignore hierarchy flyteorg/flyte-sdk