fix: skip chromedriver install if arch is not supported in docker build

Commit ready for merge.
 - Legacy-Id: 19761
This commit is contained in:
nick 2021-12-08 20:13:44 +00:00
parent bf4e7474a1
commit 516877d2db
3 changed files with 24 additions and 11 deletions

View file

@ -64,17 +64,11 @@ RUN apt-get install -qy \
yang-tools \
zsh
# Install chromedriver
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.list && \
apt-get update -y && \
apt-get install -y google-chrome-stable && \
CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \
DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER") && \
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip" && \
unzip /chromedriver/chromedriver* -d /chromedriver && \
ln -s /chromedriver/chromedriver /usr/local/bin/chromedriver && \
ln -s /chromedriver/chromedriver /usr/bin/chromedriver
# Install chromedriver if supported
COPY docker/scripts/app-install-chromedriver.sh /tmp/app-install-chromedriver.sh
RUN sed -i 's/\r$//' /tmp/app-install-chromedriver.sh && \
chmod +x /tmp/app-install-chromedriver.sh
RUN /tmp/app-install-chromedriver.sh
# Get rid of installation files we don't need in the image, to reduce size
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

View file

@ -39,6 +39,7 @@ services:
# (Adding the "ports" property to this file will not forward from a Codespace.)
db:
# image: ghcr.io/ngpixel/datatracker-db:nightly-20211208
build:
context: ..
dockerfile: docker/db.Dockerfile

View file

@ -0,0 +1,18 @@
#!/bin/bash
HOSTARCH=$(arch)
if [ $HOSTARCH == "x86_64" ]; then
echo "Installing chrome driver..."
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.list
apt-get update -y
apt-get install -y google-chrome-stable
CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*")
DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER")
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip"
unzip /chromedriver/chromedriver* -d /chromedriver
ln -s /chromedriver/chromedriver /usr/local/bin/chromedriver
ln -s /chromedriver/chromedriver /usr/bin/chromedriver
else
echo "This architecture doesn't support chromedriver. Skipping installation..."
fi