I'm having trouble running my .NET 7 Lambda locally as a Docker container.
There seems to be loads online about running python or JS lambdas, but not a lot on .NET.
I can't specify the entrypoint of the Lambda in the Docker container.
I'm using the following Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App
# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -p:PublishReadyToRun=false -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /App
COPY --from=build-env /App/out .
ENTRYPOINT ["dotnet", "LambdaLocal.dll"]
as described here: https://learn.microsoft.com/en-us/dotnet/core/docker/build-container?tabs=windows (though this is for a console app)
My Docker commands are:
docker build -t local-lambda-image -f Dockerfile .
and then:
docker run --rm -p 9000:8080 --name local-lamba-cont local-lambda-image
(taken from here: https://medium.com/dataengineerbr/how-to-run-aws-lambda-locally-on-your-computer-with-docker-containers-533a3add1b45)
When I try and run the container, the error is "Unhandled exception. System.MissingMethodException: Entry point not found in assembly 'LambdaLocal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."
I've also tried docker run -p 9000:8080 --name local-lambda-container local-lambda-image "LambdaLocal::LambdaLocal.Function::FunctionHandler" as suggested in this answer Locally test AWS Lambda container with .NET 5 web api and Lambda RIE , but I get the same error.
How do I specify the entrypoint for a .NET Lambda?