Skip to content

Commit

Permalink
Update READMEs for some scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed May 8, 2024
1 parent e7252a6 commit cb4125f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/aot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ jobs:
runtimeflavor: alpine
arch: amd64
installcommand: 'true'
- sdkflavor: alpine-aot-arm64v8
runtimeflavor: alpine
arch: arm64
installcommand: 'true'
# arm64 emulation is flaky for alpine so we will skip this for now
# - sdkflavor: alpine-aot-arm64v8
# runtimeflavor: alpine
# arch: arm64
# installcommand: 'true'

name: "${{ matrix.sdkflavor }} => ${{ matrix.runtimeflavor }}-${{ matrix.arch }}"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -102,7 +103,6 @@ jobs:
docker manifest create ghcr.io/${{github.repository_owner}}/aot-sample:latest \
ghcr.io/${{github.repository_owner}}/aot-sample:jammy-chiseled-amd64 \
ghcr.io/${{github.repository_owner}}/aot-sample:jammy-chiseled-arm64 \
ghcr.io/${{github.repository_owner}}/aot-sample:alpine-amd64 \
ghcr.io/${{github.repository_owner}}/aot-sample:alpine-arm64
ghcr.io/${{github.repository_owner}}/aot-sample:alpine-amd64
docker manifest push ghcr.io/${{github.repository_owner}}/aot-sample:latest
16 changes: 16 additions & 0 deletions src/aot-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ahead-of-time (AOT) compilation and containerization

This sample shows how an AOT-compiled console application could be containerized using the .NET SDK. This application is compiled for 4 OS/architecture combinations:

* Ubuntu x64
* Ubuntu ARM64
* Alpine x64
* Alpine ARM64 (note: in GitHub Actions this requires emulation - this is often flaky so it's been commented out of the workflow)

The various images are also combined into one 'multi-architecture' image so that the correct image is used for the host on which the container is running.

The sample includes:
* a simple [.NET Console application](./Program.cs) that echoes out the OS and architecture information when run
* a [GitHub Actions workflow](../../.github/workflows/aot.yml) showing how to combine the 4 architecture-specific images into a single multi-architecture image

This scenario is especially tricky because AOT compilation generally requires performing the publish on an OS and architecture that matches the target. This sample shows how to use the .NET SDK to build the AOT-compiled application for each target and then use the Docker CLI to combine them into a single image. Take note in the workflow how the actual image is published using the `mcr.microsoft.com/dotnet/sdk` container for that platform, but the generated image is pushed to an external registry for use later in the workflow.
11 changes: 11 additions & 0 deletions src/multi-arch-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Multi-architecture containers

This sample illustrates how you can use a combination of the .NET SDK and the Docker CLI to create
multi-architecture container images. These images will automatically use the correct architecture
for the host on which they are running.

The sample includes:
* a simple [.NET Console application](./Program.cs) that echoes out the OS and architecture information when run
* a [GitHub Actions workflow](../../.github/workflows/multi-arch-sample.yml) showing how to combine two architecture-specific images into a single multi-architecture image

This example currently has to use both the .NET CLI and a container CLI to create multi-image manifests because the .NET CLI doesn't natively know how to create multi-architecture images. If you'd use this functionality in the .NET CLI, please [+1 or comment on the tracking issue](https://github.com/dotnet/sdk-container-builds/issues/87).

0 comments on commit cb4125f

Please sign in to comment.