Skip to content

Commit ee3852a

Browse files
authored
chore: toy with xvfb-run (#133)
1 parent 0059192 commit ee3852a

File tree

10 files changed

+50
-12
lines changed

10 files changed

+50
-12
lines changed

node-playwright-chrome/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN \
1313
# Disable chrome auto updates, based on https://support.google.com/chrome/a/answer/9052345
1414
mkdir -p /etc/default && echo 'repo_add_once=false' > /etc/default/google-chrome \
1515
&& apt-get update \
16-
&& apt-get install -y wget gnupg unzip ca-certificates xvfb --no-install-recommends \
16+
&& apt-get install -y wget gnupg unzip ca-certificates xvfb xauth --no-install-recommends \
1717
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
1818
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
1919
&& sh -c 'echo "deb http://ftp.us.debian.org/debian bookworm main non-free" >> /etc/apt/sources.list.d/fonts.list' \
@@ -59,7 +59,7 @@ WORKDIR /home/myuser
5959
ENV PLAYWRIGHT_BROWSERS_PATH=/home/myuser/pw-browsers
6060

6161
# Copy source code and xvfb script
62-
COPY --chown=myuser:myuser package.json main.js chrome_test.js start_xvfb_and_run_cmd.sh /home/myuser/
62+
COPY --chown=myuser:myuser package.json main.js chrome_test.js start_xvfb_and_run_cmd.sh new_xvfb_run_cmd.sh /home/myuser/
6363

6464
# Sets path to Chrome executable, this is used by Apify.launchPuppeteer()
6565
ENV APIFY_CHROME_EXECUTABLE_PATH=/usr/bin/google-chrome
@@ -110,4 +110,5 @@ ENV XVFB_WHD=1920x1080x24+32
110110
# NOTEs:
111111
# - This needs to be compatible with CLI.
112112
# - Using CMD instead of ENTRYPOINT, to allow manual overriding
113-
CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
113+
# CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
114+
CMD ./new_xvfb_run_cmd.sh npm start --silent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" npm start --silent
4+
5+
echo "Will run command: xvfb-run -a -s \"-ac -screen 0 $XVFB_WHD -nolisten tcp\" $@"
6+
xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" "$@"

node-playwright-firefox/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN sh -c 'echo "deb http://ftp.us.debian.org/debian bookworm main non-free" >>
1818
jq \
1919
wget \
2020
p11-kit \
21+
xauth \
2122
\
2223
# Register cerificates
2324
&& chmod +x ./register_intermediate_certs.sh \
@@ -52,7 +53,7 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/home/myuser/pw-browsers
5253
ENV CRAWLEE_SKIP_BROWSER_INSTALL=1
5354

5455
# Copy source code and xvfb script
55-
COPY --chown=myuser:myuser package.json main.js firefox_test.js start_xvfb_and_run_cmd.sh /home/myuser/
56+
COPY --chown=myuser:myuser package.json main.js firefox_test.js start_xvfb_and_run_cmd.sh new_xvfb_run_cmd.sh /home/myuser/
5657

5758
# Tell Node.js this is a production environemnt
5859
ENV NODE_ENV=production
@@ -97,4 +98,5 @@ ENV XVFB_WHD=1920x1080x24+32
9798
# NOTEs:
9899
# - This needs to be compatible with CLI.
99100
# - Using CMD instead of ENTRYPOINT, to allow manual overriding
100-
CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
101+
# CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
102+
CMD ./new_xvfb_run_cmd.sh npm start --silent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" npm start --silent
4+
5+
echo "Will run command: xvfb-run -a -s \"-ac -screen 0 $XVFB_WHD -nolisten tcp\" $@"
6+
xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" "$@"

node-playwright-webkit/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ RUN apt-get update \
1010
git \
1111
procps \
1212
xvfb \
13+
xauth \
1314
# Install node
1415
&& apt-get update && apt-get install -y curl \
1516
&& curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
@@ -48,7 +49,7 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/home/myuser/pw-browsers
4849
ENV CRAWLEE_SKIP_BROWSER_INSTALL=1
4950

5051
# Copy source code and xvfb script
51-
COPY --chown=myuser:myuser package.json main.js webkit_test.js start_xvfb_and_run_cmd.sh /home/myuser/
52+
COPY --chown=myuser:myuser package.json main.js webkit_test.js start_xvfb_and_run_cmd.sh new_xvfb_run_cmd.sh /home/myuser/
5253

5354
# Tell Node.js this is a production environemnt
5455
ENV NODE_ENV=production
@@ -87,4 +88,5 @@ ENV XVFB_WHD=1920x1080x24+32
8788
# NOTEs:
8889
# - This needs to be compatible with CLI.
8990
# - Using CMD instead of ENTRYPOINT, to allow manual overriding
90-
CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
91+
# CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
92+
CMD ./new_xvfb_run_cmd.sh npm start --silent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" npm start --silent
4+
5+
echo "Will run command: xvfb-run -a -s \"-ac -screen 0 $XVFB_WHD -nolisten tcp\" $@"
6+
xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" "$@"

node-playwright/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ COPY ./register_intermediate_certs.sh ./register_intermediate_certs.sh
1111

1212
# Install libs
1313
RUN apt-get update \
14-
&& apt-get install --fix-missing -yq --no-install-recommends procps xvfb wget \
14+
&& apt-get install --fix-missing -yq --no-install-recommends procps xvfb xauth wget \
1515
&& mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \
1616
# Uninstall system NodeJs
1717
&& apt-get purge -yq nodejs \
@@ -65,7 +65,7 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
6565
ENV CRAWLEE_SKIP_BROWSER_INSTALL=1
6666

6767
# Copy source code and xvfb script
68-
COPY --chown=myuser:myuser package.json main.js chrome_test.js start_xvfb_and_run_cmd.sh /home/myuser/
68+
COPY --chown=myuser:myuser package.json main.js chrome_test.js start_xvfb_and_run_cmd.sh new_xvfb_run_cmd.sh /home/myuser/
6969

7070
# Sets path to Chrome executable, this is used by Apify.launchPuppeteer()
7171
ENV APIFY_CHROME_EXECUTABLE_PATH=/usr/bin/google-chrome
@@ -105,4 +105,5 @@ ENV XVFB_WHD=1920x1080x24+32
105105
# NOTEs:
106106
# - This needs to be compatible with CLI.
107107
# - Using CMD instead of ENTRYPOINT, to allow manual overriding
108-
CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
108+
# CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
109+
CMD ./new_xvfb_run_cmd.sh npm start --silent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" npm start --silent
4+
5+
echo "Will run command: xvfb-run -a -s \"-ac -screen 0 $XVFB_WHD -nolisten tcp\" $@"
6+
xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" "$@"

node-puppeteer-chrome/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ RUN apt-get update \
2929
procps \
3030
xdg-utils \
3131
xvfb \
32+
xauth \
3233
--no-install-recommends \
3334
# Disable chrome auto updates, based on https://support.google.com/chrome/a/answer/9052345
3435
&& mkdir -p /etc/default && echo 'repo_add_once=false' > /etc/default/google-chrome \
@@ -61,7 +62,7 @@ USER myuser
6162
WORKDIR /home/myuser
6263

6364
# Copy source code and xvfb script
64-
COPY --chown=myuser:myuser package.json main.js puppeteer_*.js start_xvfb_and_run_cmd.sh /home/myuser/
65+
COPY --chown=myuser:myuser package.json main.js puppeteer_*.js start_xvfb_and_run_cmd.sh new_xvfb_run_cmd.sh /home/myuser/
6566

6667
# Uncomment to skip the chromium download when installing puppeteer. If you do,
6768
# you'll need to launch puppeteer with:
@@ -102,4 +103,5 @@ ENV XVFB_WHD=1920x1080x24+32
102103
# NOTEs:
103104
# - This needs to be compatible with CLI.
104105
# - Using CMD instead of ENTRYPOINT, to allow manual overriding
105-
CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
106+
# CMD ./start_xvfb_and_run_cmd.sh && npm start --silent
107+
CMD ./new_xvfb_run_cmd.sh npm start --silent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" npm start --silent
4+
5+
echo "Will run command: xvfb-run -a -s \"-ac -screen 0 $XVFB_WHD -nolisten tcp\" $@"
6+
xvfb-run -a -s "-ac -screen 0 $XVFB_WHD -nolisten tcp" "$@"

0 commit comments

Comments
 (0)