dotnet-buildtools-prereqs-docker
dotnet-buildtools-prereqs-docker copied to clipboard
Improve quality of helix Dockerfiles
There are opportunities to improve the helix Dockerfiles.
- Make the Dockerfiles non-root: The Dockerfiles define a non-root user, but install
sudoand give that usersudoerpermissions. That means that the resultant container images are effectivelyrootimages. That's not great. - Base on runtime-deps: We already have official images for running .NET code in containers w/baseline dependencies. We should use them and not guess. Where we don't have the correct
runtime-depsimage, we should ask for one. - Limit dependencies: This Alma Dockerfile works so why does this Debian Dockerfile install so many packages? We should define the min set and stick to that.
- Use Python idiomatically: There are multiple opportunities to improve how we use Python. Those are listed later.
Opportunities to improve Python use:
- Install
pipone way: First, we installpipvia apt, then installpipviacurl, and then upgradepipviapip. - Adopt
venv:venvseems to have replacedvirtualenvfor most use cases.venvcomes with Python. In the case of Debian, we can install it viapython3-venvin recent Debian versions. Also, if you usevenv, you don't need to separately installpip. - Use the standard directory for
venv: Thevenvdocs suggest thatenvis the default name. We are using.vsts-env. Is that to align with scripts that are run in multiple environments? - Install packages via
venv: This approach will enable us to stop using--break-system-package
Related issues:
- https://github.com/dotnet/dnceng/issues/1312
- https://github.com/dotnet/aspnetcore/issues/48221
- https://github.com/microsoft/msquic/issues/3625
[Triage] To begin, we'll update the existing distros for which we have official runtime-deps images and change the relevant Dockerfiles in this repo to be based on those tags. At that point, we'll evaluate to see how that it's working and assess next steps.