2023-05-19

version `GLIBC_2.29' not found on Lambda invocation using AOT and .Net7

I had a .Net6 Lambda working in AWS. Recently I changed it to adopt AOT using .Net7. After deploying to AWS I get below error on Lambda invocation:

/var/task/bootstrap: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /var/task/bootstrap)

here's how the main part of my Function template looks like:

  Function:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: dotnet7
    Properties:
      FunctionName: upload-handler
      CodeUri: ./packages/upload-handler
      Handler: bootstrap
      Runtime: provided.al2
      Architectures:
      - x86_64

here's my .csproject file:

  <Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <PublishAot>true</PublishAot>
    <AssemblyName>bootstrap</AssemblyName>
    <OutputType>Exe</OutputType>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <StripSymbols>true</StripSymbols>
    <TrimMode>partial</TrimMode>
    <AWSProjectType>Lambda</AWSProjectType>
    <Version>1.0.0</Version>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

  <ItemGroup>
      <RdXmlFile Include="rd.xml" />
  </ItemGroup>
  <ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">
    <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
    <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
  </ItemGroup>
  
  <ItemGroup>
    <PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
    <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.7" />
    <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
    <PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.5" />
    <PackageReference Include="AWSSDK.S3" Version="3.7.103.51" />
    <PackageReference Include="AWSSDK.SecretsManager" Version="3.7.102.26" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
    <PackageReference Include="Serilog" Version="2.12.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
  </ItemGroup>

</Project>

and here's the main parts of my dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:7.0

# Install NativeAOT build prerequisites
RUN apt-get update && apt-get install -y --no-install-recommends clang zlib1g-dev
COPY ./src/Upload.Handler/*.csproj ./src/Upload.Handler/
COPY ./upload-handler.sln ./
RUN dotnet restore

COPY ./src/ ./src/
ARG VERSION
RUN dotnet publish ./src/Upload.Handler -r linux-x64 -c Release -o ./out/upload-handler /p:Version=$VERSION

When I run the Lambda locally using Docker there's no issue with invoking. I use docker-compose and aws cloudformation package to build and pack and aws cloudformation deploy to deploy to AWS. I also use git pipeline CI/CD and the image used there for both build and deploy is ubuntu-latest

build:
  name: Build and Test
  runs-on: ubuntu-latest

My best guess is something is missed from dockerfile and I should go with multi-stage build using ubuntu-latest in dockerfile. Can someone please put me in the right direction.



No comments:

Post a Comment