Skip to content
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

Support referencing a Layer by Digest #325

Open
baronfel opened this issue Feb 6, 2023 · 1 comment
Open

Support referencing a Layer by Digest #325

baronfel opened this issue Feb 6, 2023 · 1 comment
Labels
Area: Layer Area: Library Tasks and stories around the image and layer manipulation library Area: Task enhancement New feature or request Partner request Things that internal or external teams have explicitly requested
Milestone

Comments

@baronfel
Copy link
Member

baronfel commented Feb 6, 2023

Part of #316.

Layers for an image can come from many places - the base image, the direct content of the project being packaged, or an arbitrary registry. We should support defining new Layers to be included in the final image via MSBuild, and how those layers should be retrieved and included in the final layer.

MSBuild

A Layer reference consists of three pieces of data: the Repository the layer belongs to, the Registry the Repository is stored in, and the Digest of the layer itself. We should support defining this in MSBuild. A proposed form of this could be:

<ItemGroup>
  <ContainerLayer Include="<digest value>" Repository="<repository name>" Registry="<registry reference>" />
</ItemGroup>

For example:

<ItemGroup>
  <ContainerLayer Include="sha256:b2b4751952d24fa810a91620aee5f49a1cdf7d05b472a209920f3310f1a84bc1" Repository="dotnet/aspnet" Registry="mcr.microsoft.com" />
</ItemGroup>

These Layers would be passed into the CreateNewImage Task and included in the image.

API

The Layer class has several static factories, and the end result is making a combination of a Descriptor for the Layer and assigning a BackingFile for the layer (which can be done from the descriptor). The data from the Descriptor should be able to be retrieved by issuing a HEAD request to the v2/{repository}/{digest} endpoint - the GET at that same location returns the content while the HEAD would just give the metadata.

Once the metadata is known, the actual Registry.Push/LocalDaemon.Load commands would be responsible for downloading and moving the layer across registries. This should be something already done by our current codepaths.

Open question

  • Should we add a Type metadata to the ContainerLayer to give us a pivot for future evolution?
  • Should we add more kinds of ContainerLayer creation (e.g. arbitrary filesystem globs)?
@baronfel baronfel added enhancement New feature or request Area: Layer Area: Task Area: Library Tasks and stories around the image and layer manipulation library Partner request Things that internal or external teams have explicitly requested labels Feb 6, 2023
@baronfel baronfel added this to the 8.0.100 milestone Feb 6, 2023
@baronfel baronfel modified the milestones: 8.0.100, Backlog Jan 29, 2024
@richlander
Copy link
Member

This proposed scenario seems wasteful: dotnet/dotnet-docker#5641 (reply in thread). Maintaining a base image that only additionally contains a NuGet package seems like a bad tradeoff of effort. Ideally, SDK publish could build multiple layers, one of the app and another for any NuGet packages that should be installed, particularly tools, installed to the regular places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Layer Area: Library Tasks and stories around the image and layer manipulation library Area: Task enhancement New feature or request Partner request Things that internal or external teams have explicitly requested
Projects
None yet
Development

No branches or pull requests

2 participants