Use image metadata (labels, annotations) to drive automated image re-builds
- Dominant language
- C#
- Stars
- 181
- Forks
- 67
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 10
Description
Related: https://github.com/dotnet/dotnet-docker/issues/5531
If we added the following [OCI image annotations](https://github.com/opencontainers/image-spec/blob/main/annotations.md), we could use this information to drive our automatic image rebuilds instead of keeping track of and updating image-info files.
- **`org.opencontainers.image.source`**: URL to get source code for building the image (string). This would be equivalent to image info's [commitUrl](https://github.com/dotnet/versions/blob/f3829a5549a0a62e295503b1c2c44f4af5c3bed4/build-info/docker/image-info.dotnet-dotnet-docker-main.json#L33)
- **`org.opencontainers.image.base.digest`**: [Digest](https://github.com/opencontainers/image-spec/blob/main/descriptor.md#digests) that the image is based on (string). Equivalent to image-info's [baseImageDigest](https://github.com/dotnet/versions/blob/f3829a5549a0a62e295503b1c2c44f4af5c3bed4/build-info/docker/image-info.dotnet-dotnet-docker-main.json#L28).
- **`org.opencontainers.image.base.name`** (optional?): fully qualified base image name. I don't think this is completely necessary since we can query the Dockerfile for this information. However, we have this information, and adding it would make it easier for users to determine if our images are out of date without checking the Dockerfile.
To implement this, we'd need:
- [ ] Add the option to set annotations during image builds
- This is done using the `--annotation "foo=bar"` argument for `docker build` [[source](https://docs.docker.com/build/metadata/annotations/#add-annotations)]
- Could be turned on/off via the manifest or a build command option for ImageBuilder.
- [ ] Add the capability to use image annotations in [GetStaleImagesCommand](https://github.com/dotnet/docker-tools/blob/main/src/Microsoft.DotNet.ImageBuilder/src/Commands/GetStaleImagesCommand.cs)
- This could be either automatic or configurable in [check-base-image-subscriptions.json](https://github.com/dotnet/docker-tools/blob/main/eng/check-base-image-subscriptions.json)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.