sdk-container-builds
sdk-container-builds copied to clipboard
Support for code that requires ICU package
For any .NET code that relies on the ICU package (e.g. System.Globalization), it will fail to run in a certain set of .NET images which do not have ICU installed. Currently this set of images is limited to Alpine and distroless-style images. It would be great if the SDK container build logic handled the installation of the ICU package automatically based on the context of the app.
One simple way to detect this in the app is whether invariant globalization mode is disabled. If so, the image that's generated would automatically have the ICU package installed for you.
Doing this for Linux is pretty straightforward. For distroless, it's more tricky because you'd have to know the corresponding distroful image in order to use its package manager to retrieve the ICU package and copy that into the resulting layer of the distroless image.
I think this is going to be very hard to do. We can't support any RUN command at all in our kind of container construction model, so we can't run distro package managers to create new layers. We can do things like fetch and insert a layer by digest, and that layer could just happen to have the right file-system bits. This may be an area where container metadata (labels?) could help us learn about the functionality of the base image so we can alert the user to situations where they are looking for X and X isn't in the container. I could definitely see something like <UseDistroless>true</UseDistroless> though that would set the invariant flag property and have an influence on the default image chosen by the inference in the targets.
The way we've solved this now is to take advantage of the various -extra packages that the dotnet-docker team has made available.