XVFB fails on server.

I've deployed a playwright with chromium crawler on aws batch, with the default docker image. this is the error that I'm getting, it's mandatory for this crawler to run headful because otherwise there are some buttons that I need to click that are not loading. (Error log attached). I've also tried to create a custom slimmer image, but I bump into the same issue with Xvfb.
14 Replies
NeoNomade
NeoNomadeOPβ€’2y ago
@HonzaS , any ideas ?
extended-salmon
extended-salmonβ€’2y ago
Hi @Lukas Krivka can you please recommend a solution to this? I am also stuck here πŸ˜… Thanks!
NeoNomade
NeoNomadeOPβ€’2y ago
On my side it got fixed … aws batch was overwriting my CMD command from the dockerfile .
extended-salmon
extended-salmonβ€’2y ago
That's smooth! Still an issue for me here. If it's not to much to ask, could you please share with me the Dockerfile (at least only the part to get Xvfb running)? Thanks! πŸ™
NeoNomade
NeoNomadeOPβ€’2y ago
On what have you based your image ?
extended-salmon
extended-salmonβ€’2y ago
apify/actor-node-puppeteer-chrome:latest
NeoNomade
NeoNomadeOPβ€’2y ago
Why ? :)) It’s very big and slow
extended-salmon
extended-salmonβ€’2y ago
I want all the layers therein. Any recommendations for a slimmer image, with Xvfb and same Apify experience?
NeoNomade
NeoNomadeOPβ€’2y ago
Where are you deploying ?
extended-salmon
extended-salmonβ€’2y ago
Google Cloud Run
NeoNomade
NeoNomadeOPβ€’2y ago
FROM node:lts

RUN apt-get update && \
apt-get install -y xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable x11-apps chromium && \
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app
COPY package*.json ./
COPY *.tgz ./

RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version

COPY . ./
ENV DISPLAY=:99


CMD xvfb-run -a npm start --silent
FROM node:lts

RUN apt-get update && \
apt-get install -y xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable x11-apps chromium && \
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app
COPY package*.json ./
COPY *.tgz ./

RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version

COPY . ./
ENV DISPLAY=:99


CMD xvfb-run -a npm start --silent
I'm also working on an alpine version, but this is much quicker and easier. you can remove the ENV, and the second copy.
extended-salmon
extended-salmonβ€’2y ago
Thanks a lot. That was helpful. Will give it a shot ✨ I'd like to run the official chrome build instead of chromium and install a few other packages too. Anyways, I'll modify the Dockerfile to suit my needs. Thanks!
NeoNomade
NeoNomadeOPβ€’2y ago
What is the difference ?
extended-salmon
extended-salmonβ€’2y ago
Not much, just some personal preferences πŸ˜…

Did you find this page helpful?