Skip to content

Unexpected Dockerfile caching behaviour #13636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spearki opened this issue Oct 6, 2022 · 4 comments
Closed

Unexpected Dockerfile caching behaviour #13636

spearki opened this issue Oct 6, 2022 · 4 comments
Labels
component: image-builder feature: workspace image build meta: stale This issue/PR is stale and will be closed soon team: workspace Issue belongs to the Workspace team type: bug Something isn't working type: improvement Improves an existing feature or existing code

Comments

@spearki
Copy link

spearki commented Oct 6, 2022

Bug description

I think this is a known issue (within Gitpod at least), but it was a surprise to me that with a line in a .gitpod.Dockerfile like:

COPY the_file /here/

...changes to the_file don't actually trigger a rebuild of the image. We internally came up with the same workaround of using a dummy ENV var to break the cache manually and force a rebuild when any dependent files change.

It would be good to at least document this limitation, so devs don't have to independently discover it, usually following a period of frustration at why changes aren't being reflected in the workspace. 😞

Steps to reproduce

.gitpod.Dockerfile:

FROM gitpod/workspace-full:latest
COPY something /

Open a workspace in a repo with the above Dockerfile configured, then make a change to something, push and open a new workspace again. If a previously cached image exists, the image won't be rebuilt.

Workspace affected

No response

Expected behavior

In Docker/buildkit normally a change to a COPYied file will trigger a rebuild of that layer and following layers.

Example repository

No response

Anything else?

No response

@spearki spearki added the type: bug Something isn't working label Oct 6, 2022
@axonasif
Copy link
Member

axonasif commented Oct 6, 2022

Hey @spearki

...changes to the_file don't actually trigger a rebuild of the image. We internally came up with the same workaround of using a dummy ENV var to break the cache manually and force a rebuild when any dependent files change.

This I think is how it was intended to be. You could also use #imagebuild:

It would be good to at least document this limitation, so devs don't have to independently discover it, usually following a period of frustration at why changes aren't being reflected in the workspace. 😞

Valid point, added to the docs https://github.com/gitpod-io/website/pull/2866 🙏

@axonasif axonasif added the type: improvement Improves an existing feature or existing code label Oct 6, 2022
@david-bakin
Copy link

Should also be rebuilt if FROM refers to an image which has changed in its repo (this happens when, e.g., the tag is :latest) (see this comment).

@spearki
Copy link
Author

spearki commented Oct 10, 2022

Valid point, added to the docs gitpod-io/website#2866 🙏

Thank you! Hopefully will help others avoid this pitfall in the future.

@stale
Copy link

stale bot commented Jan 8, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the meta: stale This issue/PR is stale and will be closed soon label Jan 8, 2023
@stale stale bot closed this as completed Apr 7, 2023
@github-project-automation github-project-automation bot moved this to Awaiting Deployment in 🌌 Workspace Team Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: image-builder feature: workspace image build meta: stale This issue/PR is stale and will be closed soon team: workspace Issue belongs to the Workspace team type: bug Something isn't working type: improvement Improves an existing feature or existing code
Projects
No open projects
Status: Awaiting Deployment
Development

No branches or pull requests

3 participants