For some reason, I can’t see to get it to work. My code works locally but puppeteer is not recognized for some reason on fly.io
Hi @artyroip, just to have a bit more context on the failure at what stage is your code failing to run on fly, is it when you’re running a
fly launch or
fly deploy etc?
And what specific error are you seeing when you try to launch your code on fly?
The application deploys successfully but is not able to launch Puppeteer.
It seems as though my node application on fly cannot access the chromium instance.
There are some mildly tricky flags & such that need to be fiddled with, to run puppeteer/chromium in docker.
We’ve had good success with the
buildkite/puppeteer docker base image, which takes care of that for you. Here’s the entire contents of our Dockerfile, running on Fly:
FROM buildkite/puppeteer:latest RUN mkdir /app WORKDIR /app COPY package.json yarn.lock /app/ RUN yarn install --frozen-lockfile COPY ./ /app/ ENV PORT 8000 EXPOSE 8000 CMD yarn start
(Just notice it looks like they’ve stopped maintaining the image, though, so it might be time to find a similar base image.)
Perhaps playwright works out of the box on Fly? Docker | Playwright
I managed to get it working with the following Dockerfile:
FROM zenika/alpine-chrome:89-with-node-14 COPY package*.json ./ RUN npm install COPY . . ENV PUPPETEER_EXECUTABLE_PATH='/usr/bin/chromium-browser' EXPOSE 8080 CMD [ "node", "server.js" ]