Skip to content

Normalize feature permissions in an intetermediate stage before copying them to the final container#233

Merged
Chuxel merged 2 commits intodevcontainers:mainfrom
davidwallacejackson:feature-copy-staging
Oct 28, 2022
Merged

Normalize feature permissions in an intetermediate stage before copying them to the final container#233
Chuxel merged 2 commits intodevcontainers:mainfrom
davidwallacejackson:feature-copy-staging

Conversation

@davidwallacejackson
Copy link
Contributor

Resolves #153.

Since the underlying problem was that the permissions for features sources became corrupted and invalidated the cache, I added a new build stage that serves only to COPY the features sources and chmod them to 0600. This way, by the time the actual work of installing the features is performed the permissions will have been normalized, allowing subsequent runs to use the install layers as cache.

I tested this manually by

  1. Building a devcontainer image with this version of the CLI and pushing it to Docker Hub
  2. Clearing the buildkit cache (docker buildx prune -af)
  3. docker pulling the built image back onto my machine from Docker Hub
  4. Building the same image with the release version of the CLI and a --cache-from on the image from Docker Hub, to validate that the cache is not used by the release version. I canceled this build before it could finish, once it was clear the cache was not being used.
  5. Building the image with a --cache-from again, but using this version of the CLI (the cache was used successfully)

This might be worth adding to tests, but it'd be a bit awkward -- you'd have to basically recreate the process above and then run regexes on the output to see if you got a cache hit. I can take a crack at that, if that's a blocker for merging.

Side note: in case anybody's curious why I used an additional stage instead of simply adding a RUN chmod -R 0600 /tmp/build-features after the COPY, it's because you don't get the cache without the extra stage -- BuildKit is apparently smart enough to identify when two contexts are equal, but doesn't seem to have the same capability at the individual layer level. This demo shows this in action.

@davidwallacejackson
Copy link
Contributor Author

@microsoft-github-policy-service agree [company="Weights and Biases"]

@davidwallacejackson
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Weights and Biases"

edgonmsft
edgonmsft previously approved these changes Oct 25, 2022
Copy link
Contributor

@edgonmsft edgonmsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Sorry for the delay but it does look ok to me!

@davidwallacejackson
Copy link
Contributor Author

Hey! Sorry for the delay but it does look ok to me!

Thank you! Would you mind merging it for me?

@Chuxel
Copy link
Member

Chuxel commented Oct 26, 2022

@chrmarti wanted to take a quick look now that he is back. This look good Christof?

Copy link
Contributor

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davidwallacejackson! This looks very promising. I have left a comment for discussion.

Copy link
Contributor

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Chuxel Chuxel merged commit dadf77b into devcontainers:main Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"cacheFrom" value not considered when building dev container features

4 participants