Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@
"baseImage": "public.ecr.aws/lambda/provided:al2"
}
},
{
"displayName": "dotnet8 aot (prov.al2)",
"runtime": "provided.al2",
"handler": "bootstrap",
"path": "dotnet8_aot_on_provided_al2",
"architectures": ["x86_64", "arm64"],
"image": {
"baseImage": "public.ecr.aws/lambda/provided:al2"
}
},
{
"displayName": "dotnet8 aot (prov.al2023)",
"runtime": "provided.al2023",
"handler": "bootstrap",
"path": "dotnet8_aot_on_provided_al2023",
"architectures": ["x86_64", "arm64"],
"image": {
"baseImage": "public.ecr.aws/lambda/provided:al2023"
}
},
{
"displayName": "go1.x",
"runtime": "go1.x",
Expand Down
14 changes: 14 additions & 0 deletions s3-uploader/runtimes/dotnet8_aot_on_provided_al2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG IMAGE_TAG
FROM $IMAGE_TAG/amazonlinux:2 AS builder
ARG ARCH
WORKDIR /tmp
COPY src .
RUN yum update -y && yum install -y clang zlib-devel krb5-devel openssl-devel zip gzip tar wget
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && ./dotnet-install.sh --version latest
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN /root/.dotnet/dotnet publish --configuration Release --arch $ARCH --output /tmp/publish
RUN zip -j /tmp/code.zip /tmp/publish/bootstrap

FROM scratch
COPY --from=builder /tmp/code.zip /
ENTRYPOINT ["/code.zip"]
20 changes: 20 additions & 0 deletions s3-uploader/runtimes/dotnet8_aot_on_provided_al2/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DIR_NAME="./runtimes/$1"

if [ $2 = "x86_64" ]; then
ARCH="x64"
IMAGE_TAG="amd64"
PLATFORM="linux/amd64"
elif [ $2 = "arm64" ]; then
ARCH="arm64"
IMAGE_TAG="arm64v8"
PLATFORM="linux/arm64"
else
echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64."
exit 1
fi

rm ${DIR_NAME}/code_${2}.zip 2> /dev/null

docker build --platform ${PLATFORM} ${DIR_NAME} --build-arg ARCH=${ARCH} --build-arg IMAGE_TAG=${IMAGE_TAG} -t maxday/dotnet8_on_provided_al2_${2}
dockerId=$(docker create maxday/dotnet8_on_provided_al2_${2})
docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip
28 changes: 28 additions & 0 deletions s3-uploader/runtimes/dotnet8_aot_on_provided_al2/src/Function.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;
using System.Text.Json.Serialization;

namespace LambdaPerf;

public class Function
{
private static async Task Main()
{
await LambdaBootstrapBuilder.Create(FunctionHandler, new SourceGeneratorLambdaJsonSerializer<LambdaFunctionJsonSerializerContext>())
.Build()
.RunAsync();
}

public static StatusResponse FunctionHandler()
{
return new StatusResponse(StatusCode: 200);
}
}

public record StatusResponse(int StatusCode);

[JsonSerializable(typeof(StatusResponse))]
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
public partial class LambdaFunctionJsonSerializerContext : JsonSerializerContext
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AWSProjectType>Lambda</AWSProjectType>
<OutputType>Exe</OutputType>
<AssemblyName>bootstrap</AssemblyName>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
<TieredCompilation>false</TieredCompilation>
<InvariantGlobalization>true</InvariantGlobalization>
<OptimizationPreference>Speed</OptimizationPreference>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.10.0" />
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"configuration": "Release",
"framework": "net8.0",
"function-runtime": "provided.al2",
"function-memory-size": 256,
"function-timeout": 30,
"function-handler": "bootstrap"
}
14 changes: 14 additions & 0 deletions s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG IMAGE_TAG
FROM $IMAGE_TAG/amazonlinux:2023 AS builder
ARG ARCH
WORKDIR /tmp
COPY src .
RUN yum update -y && yum install -y clang zlib-devel krb5-devel openssl-devel zip gzip tar wget
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && ./dotnet-install.sh --version latest
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN /root/.dotnet/dotnet publish --configuration Release --arch $ARCH --output /tmp/publish
RUN zip -j /tmp/code.zip /tmp/publish/bootstrap

FROM scratch
COPY --from=builder /tmp/code.zip /
ENTRYPOINT ["/code.zip"]
20 changes: 20 additions & 0 deletions s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DIR_NAME="./runtimes/$1"

if [ $2 = "x86_64" ]; then
ARCH="x64"
IMAGE_TAG="amd64"
PLATFORM="linux/amd64"
elif [ $2 = "arm64" ]; then
ARCH="arm64"
IMAGE_TAG="arm64v8"
PLATFORM="linux/arm64"
else
echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64."
exit 1
fi

rm ${DIR_NAME}/code_${2}.zip 2> /dev/null

docker build --platform ${PLATFORM} ${DIR_NAME} --build-arg ARCH=${ARCH} --build-arg IMAGE_TAG=${IMAGE_TAG} -t maxday/dotnet8_on_provided_al2023_${2}
dockerId=$(docker create maxday/dotnet8_on_provided_al2023_${2})
docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;
using System.Text.Json.Serialization;

namespace LambdaPerf;

public class Function
{
private static async Task Main()
{
await LambdaBootstrapBuilder.Create(FunctionHandler, new SourceGeneratorLambdaJsonSerializer<LambdaFunctionJsonSerializerContext>())
.Build()
.RunAsync();
}

public static StatusResponse FunctionHandler()
{
return new StatusResponse(StatusCode: 200);
}
}

public record StatusResponse(int StatusCode);

[JsonSerializable(typeof(StatusResponse))]
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
public partial class LambdaFunctionJsonSerializerContext : JsonSerializerContext
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AWSProjectType>Lambda</AWSProjectType>
<OutputType>Exe</OutputType>
<AssemblyName>bootstrap</AssemblyName>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
<TieredCompilation>false</TieredCompilation>
<InvariantGlobalization>true</InvariantGlobalization>
<OptimizationPreference>Speed</OptimizationPreference>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.10.0" />
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"configuration": "Release",
"framework": "net8.0",
"function-runtime": "provided.al2023",
"function-memory-size": 256,
"function-timeout": 30,
"function-handler": "bootstrap"
}