From 2b85dbb76e111a942615dc5bd7c645f641afd752 Mon Sep 17 00:00:00 2001 From: Stuart Lang Date: Wed, 27 Dec 2023 23:38:41 +0000 Subject: [PATCH 1/2] Add dotnet8 aot --- manifest.json | 7 +++++ .../dotnet8_aot_on_provided_al2023/Dockerfile | 14 ++++++++++ .../dotnet8_aot_on_provided_al2023/build.sh | 17 ++++++++++++ .../src/Function.cs | 27 +++++++++++++++++++ .../src/LambdaPerf.csproj | 27 +++++++++++++++++++ .../src/aws-lambda-tools-defaults.json | 8 ++++++ .../dotnet8_aot_on_provided_al2023/src/rd.xml | 6 +++++ 7 files changed, 106 insertions(+) create mode 100644 s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile create mode 100755 s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/build.sh create mode 100644 s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/Function.cs create mode 100644 s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj create mode 100644 s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json create mode 100644 s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/rd.xml diff --git a/manifest.json b/manifest.json index c2f1d31f0b..2549a17750 100644 --- a/manifest.json +++ b/manifest.json @@ -85,6 +85,13 @@ "path": "dotnet7_aot_on_provided_al2", "architectures": ["x86_64", "arm64"] }, + { + "displayName": "dotnet8 aot (prov.al2023)", + "runtime": "provided.al2023", + "handler": "bootstrap", + "path": "dotnet8_aot_on_provided_al2023", + "architectures": ["x86_64", "arm64"] + }, { "displayName": "go1.x", "runtime": "go1.x", diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile new file mode 100644 index 0000000000..bf13715741 --- /dev/null +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile @@ -0,0 +1,14 @@ +ARG ARCH +ARG TAG_SUFFIX + +FROM plantpowerjames/dotnet-8-lambda-build:8.0.100${TAG_SUFFIX} as builder +WORKDIR /tmp +COPY src . +RUN if [ "$ARCH" = "arm64" ]; then RID="linux-arm64"; else RID="linux-x64"; fi \ + && dotnet publish -r ${RID} --output /tmp/code + +RUN zip -j /tmp/code.zip /tmp/code/* + +FROM scratch +COPY --from=builder /tmp/code.zip / +ENTRYPOINT ["/code.zip"] \ No newline at end of file diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/build.sh b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/build.sh new file mode 100755 index 0000000000..fc3f45eaf7 --- /dev/null +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/build.sh @@ -0,0 +1,17 @@ +DIR_NAME="./runtimes/$1" +ARCH=$2 + +if [ $2 = "x86_64" ]; then + TAG_SUFFIX="" +elif [ $2 = "arm64" ]; then + TAG_SUFFIX="-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_${ARCH}.zip 2> /dev/null + +docker build ${DIR_NAME} --build-arg ARCH=${ARCH} --build-arg TAG_SUFFIX="${TAG_SUFFIX}" -t maxday/dotnet8-aot_${ARCH} +dockerId=$(docker create maxday/dotnet8-aot_${ARCH}) +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${ARCH}.zip \ No newline at end of file diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/Function.cs b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/Function.cs new file mode 100644 index 0000000000..b8d83404e4 --- /dev/null +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/Function.cs @@ -0,0 +1,27 @@ +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()) + .Build() + .RunAsync(); + } + + public static StatusResponse FunctionHandler() + { + return new StatusResponse(statusCode: 200); + } +} + +public record StatusResponse(int statusCode); + +[JsonSerializable(typeof(StatusResponse))] +public partial class LambdaFunctionJsonSerializerContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj new file mode 100644 index 0000000000..2bc67e8369 --- /dev/null +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj @@ -0,0 +1,27 @@ + + + Exe + net8.0 + enable + Lambda + bootstrap + true + true + false + true + true + true + Speed + + + + + + + + + + + + + \ No newline at end of file diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json new file mode 100644 index 0000000000..7658ac6201 --- /dev/null +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json @@ -0,0 +1,8 @@ +{ + "configuration": "Release", + "function-runtime": "provided.al2023", + "function-memory-size": 256, + "function-timeout": 30, + "function-handler": "bootstrap", + "msbuild-parameters": "--self-contained true" +} \ No newline at end of file diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/rd.xml b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/rd.xml new file mode 100644 index 0000000000..36b81fb6b8 --- /dev/null +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/rd.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 32f83b75ec0ea0b23aa8689d63453b59c69c28a7 Mon Sep 17 00:00:00 2001 From: Stuart Lang Date: Wed, 27 Dec 2023 23:38:41 +0000 Subject: [PATCH 2/2] Minor improvements --- .../runtimes/dotnet8_aot_on_provided_al2023/Dockerfile | 2 +- .../dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile index bf13715741..ba3ef3e3c1 100644 --- a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/Dockerfile @@ -7,7 +7,7 @@ COPY src . RUN if [ "$ARCH" = "arm64" ]; then RID="linux-arm64"; else RID="linux-x64"; fi \ && dotnet publish -r ${RID} --output /tmp/code -RUN zip -j /tmp/code.zip /tmp/code/* +RUN zip -j /tmp/code.zip /tmp/code/bootstrap FROM scratch COPY --from=builder /tmp/code.zip / diff --git a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj index 2bc67e8369..b9cda16b9e 100644 --- a/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj +++ b/s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src/LambdaPerf.csproj @@ -8,8 +8,8 @@ true true false - true - true + true + true true Speed