Skip to content

Commit 516877d

Browse files
author
nick
committed
fix: skip chromedriver install if arch is not supported in docker build
Commit ready for merge. - Legacy-Id: 19761
1 parent bf4e747 commit 516877d

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

docker/app.Dockerfile

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,11 @@ RUN apt-get install -qy \
6464
yang-tools \
6565
zsh
6666

67-
# Install chromedriver
68-
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
69-
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
70-
apt-get update -y && \
71-
apt-get install -y google-chrome-stable && \
72-
CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \
73-
DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER") && \
74-
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip" && \
75-
unzip /chromedriver/chromedriver* -d /chromedriver && \
76-
ln -s /chromedriver/chromedriver /usr/local/bin/chromedriver && \
77-
ln -s /chromedriver/chromedriver /usr/bin/chromedriver
67+
# Install chromedriver if supported
68+
COPY docker/scripts/app-install-chromedriver.sh /tmp/app-install-chromedriver.sh
69+
RUN sed -i 's/\r$//' /tmp/app-install-chromedriver.sh && \
70+
chmod +x /tmp/app-install-chromedriver.sh
71+
RUN /tmp/app-install-chromedriver.sh
7872

7973
# Get rid of installation files we don't need in the image, to reduce size
8074
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ services:
3939
# (Adding the "ports" property to this file will not forward from a Codespace.)
4040

4141
db:
42+
# image: ghcr.io/ngpixel/datatracker-db:nightly-20211208
4243
build:
4344
context: ..
4445
dockerfile: docker/db.Dockerfile
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
HOSTARCH=$(arch)
4+
if [ $HOSTARCH == "x86_64" ]; then
5+
echo "Installing chrome driver..."
6+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
7+
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
8+
apt-get update -y
9+
apt-get install -y google-chrome-stable
10+
CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*")
11+
DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER")
12+
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip"
13+
unzip /chromedriver/chromedriver* -d /chromedriver
14+
ln -s /chromedriver/chromedriver /usr/local/bin/chromedriver
15+
ln -s /chromedriver/chromedriver /usr/bin/chromedriver
16+
else
17+
echo "This architecture doesn't support chromedriver. Skipping installation..."
18+
fi

0 commit comments

Comments
 (0)