AWS AL2 image for building aot-compiled arm dotnet 8 lambdas.
10K+
To use it:
dotnet tool install -g Amazon.Lambda.Tools
dotnet new install Amazon.Lambda.Templates
dotnet new lambda.NativeAOT -n MyFn
net8.0 instead of net7.0 docker run --rm --volume .:/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg \
smashedtoatoms/al2-dotnet8-preview-aot-builder:latest \
dotnet publish "/tmp/source/src/MyFn" \
--output "/tmp/source/src/MyFn/bin/Release/net8.0/publish"\
--configuration "Release" \
--framework "net8.0" /p:GenerateRuntimeConfigurationFiles=true \
--runtime linux-arm64 \
--self-contained True
var myFn = new Function(this, "MyFn", new FunctionProps
{
Architecture = Architecture.ARM_64,
Runtime = Runtime.PROVIDED_AL2,
Code = Code.FromAsset("../MyFn/bin/Release/net8.0/publish"),
Handler = "bootstrap",
MemorySize = 512,
Timeout = Duration.Seconds(10),
});
FROM public.ecr.aws/amazonlinux/amazonlinux:2
# Set up environment variables for package management
ENV \
DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
DOTNET_NOLOGO=true \
DOTNET_SDK_VERSION=8.0.100-preview.7.23376.3 \
DOTNET_USE_POLLING_FILE_WATCHER=true \
NUGET_XMLDOC_MODE=skip \
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetSDK-Debian-12-arm64 \
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true \
PATH="/usr/share/dotnet:${PATH}"
# Install dependencies
RUN set -ex \
&& yum groupinstall -yq "Development Tools" \
&& yum install -yq wget clang zlib-devel openssl-devel
# Install .NET SDK
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \
&& chmod +x dotnet-install.sh \
&& ./dotnet-install.sh --version $DOTNET_SDK_VERSION --install-dir /usr/share/dotnet \
&& rm dotnet-install.sh \
&& dotnet help
# Install PowerShell global tool
RUN powershell_version=7.4.0-preview.3 \
&& curl -fSL --output PowerShell.Linux.arm64.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Linux.arm64.$powershell_version.nupkg \
&& powershell_sha512='4a5d48199ed8b66446b7cff109f9864a9b0cea138d28f9aef7211accbf246ce2ee1f8f3aae23e2d6be2b532dd3b548516dacdb11f83794a17575e6a7335a73d2' \
&& echo "$powershell_sha512 PowerShell.Linux.arm64.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install -g Amazon.Lambda.Tools \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.arm64 \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.arm64.$powershell_version.nupkg \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
# To reduce image size, remove the copy nupkg that nuget keeps.
&& find /usr/share/powershell -print | grep -i '.*[.]nupkg$' | xargs rm
There are probably better ways to do this, but I wanted to try out dotnet 8 preview, and this lets me do it.
Content type
Image
Digest
sha256:d89666c7c…
Size
665.1 MB
Last updated
about 3 years ago
docker pull smashedtoatoms/al2-dotnet8-preview-aot-builder