Hi,
i am running into an error while performing html to pdf generation using puppeteer ,i am using docker to deploy on aws but when i excute my code i am getting error
"Read-only file system : '/var/task/chrome-linux64.zip'"
Thanks
Hi,
i am running into an error while performing html to pdf generation using puppeteer ,i am using docker to deploy on aws but when i excute my code i am getting error
"Read-only file system : '/var/task/chrome-linux64.zip'"
Thanks
For further actions, you may consider blocking this person and/or reporting abuse
Labby -
Mahrukh Adeel -
keploy -
Hamdi KHELIL -
Top comments (2)
The error "Read-only file system: '/var/task/chrome-linux64.zip'" indicates that your Puppeteer process is trying to write to a location in the file system that is mounted as read-only. This is a common issue when deploying applications in environments like AWS Lambda where the file system may be restricted.
To address this issue, you can take the following steps:
Modify your Puppeteer setup to extract the browser to the /tmp directory. Here’s how you can do it in your code:
Install the necessary packages:
Here’s an example Dockerfile:
You can create a layer with the necessary binaries and dependencies, and then configure your Lambda function to use this layer.
Example Lambda Function with Layers
Here’s an example of how to set up an AWS Lambda function with Puppeteer using layers:
Hope it helps, good luck !
Thanks for the quick reply ,
i am using PuppeteerSharp for document generation
and below is my backend code
public void ProcessRecord(ReportModel report, ILambdaContext context)
{
var mq = new MessageQueue { Message = JsonConvert.SerializeObject(report) };
_messageQueue.Add(mq);
var status = "Completed";
if (string.IsNullOrEmpty(report.GetDocumentPath))
return;
}
and below is docker file code :
ARG CHROME_VERSION="81.0.4044.138-1"
RUN apt-get update && apt-get -f install && apt-get -y install wget gnupg2 apt-utils
RUN wget --no-verbose -O /tmp/chrome.deb dl.google.com/linux/chrome/deb/poo... \
&& apt-get update \
&& apt-get install -y /tmp/chrome.deb --no-install-recommends --allow-downgrades fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
&& rm /tmp/chrome.deb
Add user, so we don't need --no-sandbox.
same layer as npm install to keep re-chowned files from using up several hundred MBs more space
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser
Run everything after as non-privileged user.
USER pptruser
END PUPPETEER RECIPE
ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/google-chrome-unstable"
and now i am getting below error :
System.AggregateException: One or more errors occurred. (Failed to launch browser! )
---> PuppeteerSharp.ProcessException: Failed to launch browser!
at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 83
at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 89
at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 65
at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 98
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at PIB.DocumentGenerator.Data.Services.DocumentProcessService.ProcessRecord(ReportModel report, ILambdaContext context) in /var/task/PIB.DocumentGenerator.Data/Services/DocumentProcessService.cs:line 120
Failed to launch browser! /var/task/Chrome/Linux-122.0.6261.111/chrome-linux64/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file