Skip to content

Commit

Permalink
Install X11 server for headful.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavpandeyvpz committed Sep 22, 2023
1 parent 8344716 commit 31b92b9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
27 changes: 20 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
FROM debian:bookworm-slim

RUN apt-get update && \
apt-get install -y gnupg unzip wget
apt-get install -y gnupg unzip wget && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN apt-get update && \
apt-get install -y xvfb && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get update

RUN apt-get install -y google-chrome-stable && \
RUN apt-get update && \
apt-get install -y google-chrome-stable && \
rm /etc/apt/sources.list.d/google-chrome.list && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN CHROME_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+)(\.[0-9]+){3}.*/\1/") \
CHROMEDRIVER_VERSION=$(wget -qO- https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_$CHROME_VERSION | sed 's/\r$//') \
CHROMEDRIVER_URL=https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$CHROMEDRIVER_VERSION/linux64/chromedriver-linux64.zip; \
wget --no-verbose -O /tmp/chromedriver.zip $CHROMEDRIVER_URL && \
wget -q -O /tmp/chromedriver.zip $CHROMEDRIVER_URL && \
rm -rf /opt/chromedriver && \
unzip /tmp/chromedriver.zip -d /opt/chromedriver && \
rm /tmp/chromedriver.zip && \
mv /opt/chromedriver/chromedriver-linux64/chromedriver /opt/chromedriver/chromedriver-$CHROME_DRIVER_VERSION && \
chmod 755 /opt/chromedriver/chromedriver-$CHROME_DRIVER_VERSION && \
ln -fs /opt/chromedriver/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
mv /opt/chromedriver/chromedriver-linux64/chromedriver /opt/chromedriver/chromedriver-$CHROMEDRIVER_VERSION && \
chmod 755 /opt/chromedriver/chromedriver-$CHROMEDRIVER_VERSION && \
ln -fs /opt/chromedriver/chromedriver-$CHROMEDRIVER_VERSION /usr/bin/chromedriver

RUN apt-get update && \
apt-get install -y supervisor && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

COPY supervisor.conf /etc/supervisor/supervisor.conf

RUN groupadd -r chrome && \
useradd -rm -g chrome -G audio,video chrome
Expand All @@ -30,5 +42,6 @@ USER chrome
WORKDIR /home/chrome

ENV CHROMEDRIVER_PORT 4444
ENV DISPLAY :99

CMD ["sh", "-c", "chromedriver --allowed-ips= --allowed-origins=* --port=${CHROMEDRIVER_PORT}"]
CMD ["sh", "-c", "supervisord -c /etc/supervisor/supervisor.conf --logfile /dev/null --pidfile /dev/null"]
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ version: '3'
services:
chromedock:
image: syncloudsoftech/chromedock
environment:
PORT: '4444' # optional
ports:
- '4444:4444'
```
Expand Down
15 changes: 15 additions & 0 deletions supervisor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[supervisord]
nodaemon=true

[program:chromedriver]
command=/usr/bin/chromedriver --allowed-ips= --allowed-origins=* --port=4444
process_name=%(program_name)s
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
user=chrome

[program:xvfb]
command=/usr/bin/Xvfb :99 -ac -screen 0 1280x720x16 -nolisten tcp
process_name=%(program_name)s
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0

0 comments on commit 31b92b9

Please sign in to comment.