-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Container offering for supporting Native AOT scenarios #4129
Comments
If there were to be separate images only intended for Native AOT deployments, this would be limited to just |
Also consider containers that support building NativeAOT apps. Right now:
Is needed in order to publish with |
[Triage] |
One interesting aspect of native AOT publishing is the following from https://learn.microsoft.com/dotnet/core/deploying/native-aot/:
This could have implications on which OS versions we make the SDK available on. For 7.0, for example, we only provide Ubuntu 22.04 images. |
sdk: runtime: PublishAot=true |
Note that in .NET 8, |
[Triage] The question then is around the SDK and what its requirements are. Is it possible to have a single SDK image to satisfy all scenarios for that as well? |
The current runtime-deps image works for NativeAOT deployments already. It is bigger than strictly necessary, but that is not the end of the world. If somebody wants the absolute minimal footprint, they can build their own.
The requirements are documented in https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/#prerequisites . I do not think it is a good idea to install these prerequisites to SDK image used everywhere. They have non-trivial size. |
After some evaluation of this scenario, I've come to the conclusion that we should do something here. There was initial concern about this because the naive (and not unreasonable) reaction is that we're adding a whole other pivot to our container image catalog. I propose that we provide an excellent experience for Native AOT for one of our support Linux variants, specifically Ubuntu. Ubuntu is a great choice for two reasons: We'd offer two images (for x64 and Arm64; Arm32 is debatable):
Perhaps crazy, but we could just install these two components in the Ubuntu SDK image and just call it good. For folks that are unhappy with the size increase, they could use the Debian image. Clearly, we'd need to see the actual size increase to decide if this is OK. If Chiseled is a step too far for some folks, they can go DIY (which is status quo). |
currently i cant build for arm64 on amd64 with docker. always fails at restoring nuget packages: i tried to run
|
here is what i tried building arm64 with amd64 docker image (since apparently sdk does not support qemu):
unfortunately fails at running
EDIT:
|
Let's move the cross-targeting topic to dotnet/runtime#88971 |
@richlander - what is the reasoning/thinking for supporting one variant versus a complete matrix? I can draw some conclusions but would like to hear yours. |
I did a bit of digging to provide more informed insight. $ docker images mcr.microsoft.com/dotnet/sdk
REPOSITORY TAG IMAGE ID CREATED SIZE
mcr.microsoft.com/dotnet/sdk 8.0-preview-jammy 174be2ee75d7 6 days ago 818MB
$ docker images sdk-8.0-preview-jammy-clang
REPOSITORY TAG IMAGE ID CREATED SIZE
sdk-8.0-preview-jammy-clang latest 5330d6b29eed 28 seconds ago 1.63GB
$ cat Dockerfile.ubuntu
FROM mcr.microsoft.com/dotnet/sdk:8.0-preview-jammy
RUN apt-get update && apt-get -y install clang zlib1g-dev That obviously means that we cannot add these packages to an existing SDK. My thinking is that we should do the following:
That approach is coherent, delivers significant value, and is focused on E2E workflows. Names of the repos TBD. Those are provided as placeholders. |
I've now played with Dockerfiles that support native AOT a lot more as part of #4742. I thought it would be useful to share a vision for what the user Dockerfile would look like. FROM mcr.microsoft.com/dotnet/aot-sdk:8.0-jammy AS build
ARG TARGETARCH
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.csproj .
RUN dotnet restore -a $TARGETARCH
# copy and publish app and libraries
COPY . .
RUN dotnet publish -a $TARGETARCH --no-restore -o /app releasesapi.csproj
RUN rm /app/*.dbg /app/*.Development.json
# final stage/image
FROM mcr.microsoft.com/dotnet/aot-deps:8.0-jammy-chiseled
WORKDIR /app
COPY --from=build /app .
USER $APP_UID
ENTRYPOINT ["./releasesapi"] Close watchers will notice that this Dockerfile removes almost everything that makes a native AOT Dockerfile special leaving it to look remarkably similar to a regular CoreCLR app. Exactly. The assumption is that the project file has all the properties that specify native AOT. This design relies on manifest tags. There is a design choice about whether to make the This is the size difference: [rich@kelowna releasesapi-aot]$ docker images ubuntu-sdk
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu-sdk latest 7a1192602288 4 hours ago 1.8GB
[rich@kelowna releasesapi-aot]$ docker images ubuntu-cross-sdk
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu-cross-sdk latest cdfbb3b521cb 6 hours ago 1.88GB They are almost identical. So, size doesn't seem to be an important metric. I was originally proposing That means that users could |
@jkotas, what are the absolute minimum requirements for native AOT deployments, are they documented somewhere? From my testing, I'm able to run native AOT ASP.NET apps directly on the base images - |
Answered here: #4748 (comment) |
This could also benefit the |
Images are available in |
Maybe @baronfel can comment on support for this? |
That would be an ideal next step - we already look at the presence of |
Cross-posting my comment: #4859 (comment)
|
@devnoname120 We are keeping a close eye on the pull stats for these images. At the moment, there's not enough usage of the preview images to warrant publishing so many new images. I left a comment on your linked PR - you can get really close to the same thing by installing the additional packages needed for AOT compilation in your SDK image. And if you wanted to use Ubuntu instead of Debian, for example, you could check out the individual Dockerfile that we publish for the nightly AOT SDK images (it also contains some extra packages for cross-compilation support - not all packages are strictly necessary) https://github.com/dotnet/dotnet-docker/blob/nightly/src/sdk/8.0/jammy-aot/amd64/Dockerfile. Also related: #5020 |
We need to determine if and how we should adjust the set of container images we provide to meet the needs of Native AOT scenarios. It looks like the set of package dependencies that are needed for those scenarios is different from standard deployments.
For example, there is work to remove a dependency on
libstdc++
: dotnet/runtime#76655. That likely has no impact on the current full versions of Debian, Ubuntu, and Mariner since that package is installed by default. But it would impact Alpine, distroless Mariner, and chiseled Ubuntu since it's explicitly being added in those images.We should avoid the inclusion of any unnecessary packages in our images. It leads to a larger image size and increased exposure to vulnerabilities.
The text was updated successfully, but these errors were encountered: