sdk-container-builds
sdk-container-builds copied to clipboard
Support Image History
The history field of the Image Manifest is used as a log of what commands/who made modifications to the image. It's generally added to on a layer-by-layer basis, and if it is maintained correctly, you get nice displays in outputs like docker image history:
➜ docker history container-app-tres:0.0.6
IMAGE CREATED CREATED BY SIZE COMMENT
229b57e74fb4 7 seconds ago dotnet publish -p:PublishProfile=DefaultCont… 8.38MB A dynamically-generated image layer from the .NET SDK
<missing> 10 days ago /bin/sh -c #(nop) COPY dir:b0ac707752044c30c… 21.3MB
<missing> 10 days ago /bin/sh -c #(nop) ENV ASPNET_VERSION=7.0.0-… 0B
<missing> 10 days ago /bin/sh -c ln -s /usr/share/dotnet/dotnet /u… 24B
<missing> 10 days ago /bin/sh -c #(nop) COPY dir:99ddbc873c8fc6285… 72.9MB
<missing> 10 days ago /bin/sh -c #(nop) ENV DOTNET_VERSION=7.0.0-… 0B
<missing> 10 days ago /bin/sh -c #(nop) ENV ASPNETCORE_URLS=http:… 0B
<missing> 10 days ago /bin/sh -c apt-get update && apt-get ins… 37MB
<missing> 2 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ADD file:0eae0dca665c7044b… 80.4MB
and the Docker Desktop image history view:

A simple addition to the AddLayer function makes this possible:
var history = new JsonObject();
history["created"] = DateTime.UtcNow;
history["author"] = ".NET SDK";
history["created_by"] = "dotnet publish -p:PublishProfile=DefaultContainer";
history["comment"] = "A dynamically-generated image layer from the .NET SDK";
config["history"]!.AsArray().Add(history);
But I wanted to slow down and think about what data we would want to embed in this structure. The spec has the following to say about it:

Should we put package/SDK versions in this? Should the created date be the actual now? I know we've been thinking about determinism in this project, but the history property isn't part of digest calculation.