i’m trying to generate pdf file for this service i’m building with typescript. now everything works locally but i can’t deploy it to AWS as it exceeds the lambda limit. now i am trying to dockerize it and it get’s deployed but throws the following error.
"Failed to launch the browser process!n/var/task/node_modules/puppeteer/.local-chromium/linux-1036745/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directorynnnTROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.mdn"
this is where it fails
const browser = await puppeteer.launch({
headless: false,
args: args,
ignoreDefaultArgs: ['--disable-extensions'],
executablePath: '/usr/bin/chromium-browser',
});
const page = await browser.newPage();
and here is my Dockerfile
FROM public.ecr.aws/lambda/nodejs:14.2022.09.09.11
ARG FUNCTION_DIR="/var/task"
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}
# Copy package.json
COPY package.json ${FUNCTION_DIR}
# Install NPM dependencies for function
RUN npm install
# Copy handler function and tsconfig
COPY . ${FUNCTION_DIR}
# Compile ts files
RUN npm run build
# Set the CMD to your handler
CMD [ "dist/src/generate.pdf" ]
5
Answers
i did a workaround from here so i changed my Dockerfile as below
and my code as below
now i'm getting another error
if i remove the
executablePath: '/usr/bin/google-chrome'
then still getting error but diffferent onei, then found another solution here
so i changed my Dockerfile
and my code as same before
and now i get a different error
now i have tried another solution from here
my Dockerfile
and my code
and i get this error
"Protocol error (Target.setAutoAttach): Target closed."
updated my Dockerfile
i’m using a build and copying to my own build
but getting this error:
"Failed to launch the browser process! spawn /usr/bin/google-chrome ENOENTnnnTROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.mdn"
A Working example…
Dockerfile
Puppeteer config