Hi,
I was able to create a lambda function using AWS lambda project - .Net Core C#. (empty function blueprint) and turn it into a docker image. Now the entry point is correctly set and also I was able to add playwright to the image. But, when I try to launch a chromium brower in the lambda. I am getting the following error:-
"errorType": "TargetClosedException", pid=42\n[pid=42][err] /ms-playwright/chromium-1112/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
- [pid=42][err] /ms-playwright/chromium-1112/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
Did anyone run into this issue before?
here is the docker file that I have:-
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy as base
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright &&
cd /ms-playwright &&
pwsh -Command "dotnet new console" &&
echo '<?xml version="1.0" encoding="utf-8"?><configuration><packageSources><add key="local" value="/tmp/"/></packageSources></configuration>' > nuget.config &&
pwsh -Command "dotnet add package Microsoft.Playwright" &&
pwsh -Command "dotnet add package AWSSDK.S3" &&
pwsh -Command "dotnet build" &&
pwsh -Command "./bin/Debug/net8.0/playwright.ps1 install --with-deps" &&
apt-get update &&
apt-get install -y \libnss3 &&
rm -rf /var/lib/apt/lists/* &&
rm -rf /tmp/* &&
chmod -R 777 /ms-playwright
Use the specified .NET SDK image as the build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
Copy the project file and restore dependencies
COPY ["AWSLambdaURLToPDFPOC.csproj", "base/"]
RUN dotnet restore "base/AWSLambdaURLToPDFPOC.csproj"
Copy the rest of the source code
COPY . .
Build the app
WORKDIR "/src"
RUN dotnet build "AWSLambdaURLToPDFPOC.csproj" --configuration Release --output /app/build
Publish the app
FROM build AS publish
RUN dotnet publish "AWSLambdaURLToPDFPOC.csproj"
--configuration Release
--runtime linux-x64
--self-contained false
--output /app/publish
-p:PublishReadyToRun=true
Use the latest AWS Lambda .NET base image as the runtime image
FROM public.ecr.aws/lambda/dotnet:latest AS final
WORKDIR /var/task
Copy the published app from the publish stage
COPY --from=publish /app/publish .
Copy Playwright installation from the base stage
COPY --from=base /ms-playwright /ms-playwright
Set permissions for Playwright
RUN chmod +x .playwright/node/*/node
Set the entry point for the Lambda function
CMD ["AWSLambdaURLToPDFPOC::AWSLambdaURLToPDFPOC.Function::FunctionHandler"]
As you can see, I have tried installing libnss3.so but no luck.
Please feel free to ask for more information, and please suggest any other approaches that you think might work. I don't mind trying them out.