Files
Vladimir Kozhukalov 63aac0c7ac Build arm64 images
Signed-off-by: Vladimir Kozhukalov <kozhukalov@gmail.com>
Change-Id: Ica2914e7d31ecad50896e5d2de4894df1cbff644
2026-02-05 10:34:59 -06:00

65 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
set -xeo pipefail
export DEBIAN_FRONTEND=noninteractive
export VENV=/osh-selenium_venv
apt-get update
apt-get -y upgrade
apt-get install --no-install-recommends -y \
lsb-release \
gnupg \
ca-certificates \
curl \
unzip \
wget \
python3 \
python3-pip \
python3-venv \
jq
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub \
| gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg
chmod 0644 /etc/apt/keyrings/google-chrome.gpg
if [[ "${TARGETARCH:-}" == "arm64" ]]; then
echo "deb [arch=arm64 signed-by=/etc/apt/keyrings/google-chrome.gpg] https://dl.google.com/linux/chrome/deb/ stable main" \
| tee /etc/apt/sources.list.d/google-chrome.list
else
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] https://dl.google.com/linux/chrome/deb/ stable main" \
| tee /etc/apt/sources.list.d/google-chrome.list
fi
cat >/etc/apt/apt.conf.d/99retries-timeouts <<'EOF'
Acquire::Retries "10";
Acquire::https::Timeout "120";
Acquire::http::Timeout "120";
Acquire::ForceIPv4 "true";
EOF
apt-get update
apt search google-chrome
apt-get install --no-install-recommends -y google-chrome-stable
python3 -m venv ${VENV}
source ${VENV}/bin/activate
python -m pip install --upgrade --no-cache-dir pip
python -m pip install --no-cache-dir selenium
CHROME_VERSION=$(dpkg -s google-chrome-stable | grep -Po '(?<=^Version: ).*' | awk -F'.' '{print $1"."$2"."$3}')
echo "Detected Chrome version: ${CHROME_VERSION}"
DRIVER_URL=$(wget -qO- https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r --arg chrome_version "$CHROME_VERSION" '.channels | (.Stable, .Beta) | .downloads.chromedriver[] | select(.platform=="linux64" and (.url | test($chrome_version))).url')
if [[ -z "${DRIVER_URL}" ]]; then
DRIVER_URL=$(wget -qO- https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json | jq -r --arg chrome_version "$CHROME_VERSION" '[ .versions[] | select(.version | startswith($chrome_version)) | .downloads.chromedriver[] | select(.platform=="linux64") | .url ] | last')
fi
echo "Downloading ChromeDriver from: ${DRIVER_URL}"
wget -O /tmp/chromedriver.zip "${DRIVER_URL}"
unzip -j /tmp/chromedriver.zip -d /etc/selenium
apt-get purge --autoremove -y unzip jq
rm -rf /var/lib/apt/lists/* /tmp/*