Skip to content

Always cache apt metadata and downloads outside the image #989

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DavidS-ovm
Copy link

This change uses cache mounts in the generated Dockerfiles for features to ensure that apt metadata and downloaded packages remain available throughout the build process without ever getting baked into layers. To make life easier for feature implementations, this also runs apt update once before the feature build, so that the metadata cache is up-to-date.

This has the following benefits:

  • reduced build-time costs: apt metadata is only downloaded once
  • smaller layer size: features cannot accidentally include downloaded packages in their layer (see Add apt clean to reduce layer size features#1298)
  • reduced complexity: features do not have to worry about apt caching and cache cleaning
  • optionally, if building on a caching buildkit service like depot.dev, the cache is re-used across builds, further reducing build-time

This change uses cache mounts in the generated Dockerfiles for features
to ensure that apt metadata and downloaded packages remain available
throughout the build process without ever getting baked into layers. To
make life easier for feature implementations, this also runs `apt update`
once before the feature build, so that the metadata cache is up-to-date.

This has the following benefits:
* reduced build-time costs: apt metadata is only downloaded once
* smaller layer size: features cannot accidentally include downloaded packages in their layer (see devcontainers/features#1298)
* reduced complexity: features do not have to worry about apt caching and cache cleaning
* optionally, if building on a caching buildkit service like depot.dev, the cache is re-used across builds, further reducing build-time
@DavidS-ovm
Copy link
Author

@microsoft-github-policy-service agree company="Overmind Tech, Inc."

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.

1 participant