This app demonstrates publishing an app as native AOT in containers.
A similar console app sample supports single file deployment (non-AOT scenario). This app could also be deployed that way.
You can build and run the sample:
docker build --pull -t releasesapi 'https://github.com/dotnet/dotnet-docker.git#:samples/releasesapi'
docker run --rm -it -p 8000:8080 -e ASPNETCORE_HTTP_PORTS=8080 releasesapi
It exposes two endpoints:
http://localhost:8000/releases
http://localhost:8000/healthz
The app is intended as a sort of compliance report for .NET. The report includes supported major releases and those recently out of support. It includes the latest and latest security patch versions for each of those major releases.
This same information is available from the release JSON files that the team maintains, but that requires a bit of code to provide the same report.
The sample includes several Dockerfiles with varying functionality. The base images they use are currently experimental (not supported).
These Dockerfiles work on AMD64 and ARM64 when targeting the same architecture.
- Ubuntu Chiseled
- Alpine Linux
- Azure Linux Distroless
- Debian
- Ubuntu Chiseled with Globalization support
- Alpine Linux with Globalization support
- Azure Linux Distroless with Globalization support
For cross-compilation support, you will need to install a few extra packages during the build.
The following Dockerfiles demonstrate how to add cross-compilation support for native AOT .NET Dockerfiles. This means you can build ARM64 images using an AMD64 machine and vice-versa.
For example, to build an Ubuntu ARM64 native AOT .NET image on an AMD64 machine, you can run the following command:
docker build --pull --platform linux/arm64 -t releasesapi -f Dockerfile.ubuntu-cross-x64-arm64 'https://github.com/dotnet/dotnet-docker.git#:samples/releasesapi'
Additional native AOT cross-compilation options are described in the dotnet/runtime repo.
Note that non-AOT .NET images don't need any additional packages for cross-compilation. See Building images for a specific platform for more information.