<#766 Include dockerignore content in image hash t...
# flyte-github
a
#766 Include dockerignore content in image hash to invalidate cache on changes Pull request opened by Copilot on <!date^1772946241^{date_short}|2026-03-08T05:04:01Z> The image cache key ignored
.dockerignore
contents, so editing
.dockerignore
did not trigger rebuilds and stale images were reused. • 🧭 Hashing logic • Add a shared helper to hash both path and file contents. • Include DockerIgnore layers’ file contents in the image digest. • When no DockerIgnore layer is provided, hash the project root
.dockerignore
(if present) to influence the image tag. • ✅ Tests • Add helper to assert dockerignore edits change image URIs. • Cover both root
.dockerignore
and custom dockerignore layers; update deterministic hash expectation with init-config mocked to avoid repo coupling. Example: img = Image.from_debian_base().with_dockerignore(Path("custom.dockerignore")) print(img.uri) # changes when custom.dockerignore contents change Original prompt
---
This section details on the original issue you should resolve
<issue_title>Editing .dockerignore does not invalidate image build cache</issue_title>
<issue_description>## Summary
When editing a
.dockerignore
file for a task environment, the image build cache is not invalidated and the environment image is not rebuilt. The only workaround is to modify the
.toml
file to force a rebuild.
Expected Behavior
Changes to
.dockerignore
should invalidate the image build cache and trigger a rebuild of the task environment image, since
.dockerignore
affects which files are included in the Docker build context and can change the resulting image.
Actual Behavior
Editing
.dockerignore
has no effect on cache invalidation. The previously cached image continues to be used until the
.toml
configuration file is modified.
Reproduction Steps
1. Have a task environment with a working image build
2. Edit the
.dockerignore
file (e.g., add or remove an entry)
3. Trigger a build — observe that the cached image is reused without rebuilding
4. Modify the
.toml
file (e.g., add a comment) — observe that the image is now rebuilt
Impact
This can lead to stale images being used that include or exclude files incorrectly based on outdated
.dockerignore
rules.</issue_description>
Comments on the Issue (you are @copilot in this section)
• Fixes flyteorg/flyte#6990 --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey. flyteorg/flyte-sdk