Skip to content

Commit 2a99322

Browse files
committed
Refactor Dockerfile to streamline Chrome and ChromeDriver installation; set display port to avoid crashes
1 parent 5e4ff04 commit 2a99322

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

Dockerfile

+12-20
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,18 @@
22
FROM ghcr.io/astral-sh/uv:python3.11-bookworm
33

44
# Install Chrome and dependencies
5-
RUN apt-get update && apt-get install -y \
6-
wget \
7-
gnupg \
8-
curl \
9-
unzip \
10-
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
11-
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
12-
&& apt-get update \
13-
&& apt-get install -y \
14-
google-chrome-stable \
15-
&& rm -rf /var/lib/apt/lists/*
16-
17-
# Install ChromeDriver
18-
RUN CHROME_VERSION=$(google-chrome --version | awk '{print $3}' | awk -F'.' '{print $1}') \
19-
&& CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION") \
20-
&& wget -q "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" \
21-
&& unzip chromedriver_linux64.zip \
22-
&& mv chromedriver /usr/local/bin/ \
23-
&& chmod +x /usr/local/bin/chromedriver \
24-
&& rm chromedriver_linux64.zip
5+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
6+
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
7+
RUN apt-get -y update
8+
RUN apt-get install -y google-chrome-stable
9+
10+
# install chromedriver
11+
RUN apt-get install -yqq unzip
12+
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
13+
RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
14+
15+
# set display port to avoid crash
16+
ENV DISPLAY=:99
2517

2618
# Create a non-root user
2719
RUN useradd -m -u 1000 appuser

0 commit comments

Comments
 (0)