From e6ffa64d9d7622327b134c8397f59edf832e4299 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lo=C3=AFc=20Guitaut?= Date: Wed, 20 Mar 2024 22:48:52 +0100 Subject: [PATCH] Use Chromium instead of Chrome (#782) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Chrome isn’t available yet for aarch64, but Chromium (which is basically the same browser without the proprietary bits from Google) is shipped by Debian. They also ship a Chrome driver compiled for aarch64. By using Chromium instead of Chrome, we unify how we do things regardless of the architecture used in the generated image. --- image/discourse_dev/Dockerfile | 1 + image/discourse_dev/install-selenium | 11 +---------- image/discourse_test/Dockerfile | 8 +++----- image/discourse_test/install-chrome | 20 -------------------- 4 files changed, 5 insertions(+), 35 deletions(-) delete mode 100755 image/discourse_test/install-chrome diff --git a/image/discourse_dev/Dockerfile b/image/discourse_dev/Dockerfile index 65e79be..26e61d5 100644 --- a/image/discourse_dev/Dockerfile +++ b/image/discourse_dev/Dockerfile @@ -39,6 +39,7 @@ ADD ensure-database /etc/runit/1.d/ensure-database ADD install-rust /tmp/install-rust ADD install-selenium /tmp/install-selenium RUN /tmp/install-selenium +RUN apt update && apt install -y chromium-driver firefox-esr # Install & Configure MailHog (https://github.com/mailhog/MailHog) RUN wget -qO /tmp/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.1/MailHog_linux_amd64\ diff --git a/image/discourse_dev/install-selenium b/image/discourse_dev/install-selenium index 2cf6f74..93dba2d 100755 --- a/image/discourse_dev/install-selenium +++ b/image/discourse_dev/install-selenium @@ -1,13 +1,9 @@ #!/bin/bash set -e -# The chrome webdriver isn’t available for the aarch64 architecture (yet). We -# have to rely on the geckodriver instead, so we’re just installing firefox and -# not even chromium. # The Selenium gem isn’t shipped with the `selenium-manager` binary for aarch64 -# either (yet). So we have to compile it ourselves. +# (yet). So we have to compile it ourselves. if [ "$(dpkg --print-architecture)" = "arm64" ]; then - apt update && apt install -y firefox-esr cd /tmp /tmp/install-rust git clone --depth 1 --no-checkout https://github.com/SeleniumHQ/selenium.git @@ -20,9 +16,4 @@ if [ "$(dpkg --print-architecture)" = "arm64" ]; then rustup self uninstall -y cd / rm -rf /tmp/* -else - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - &&\ - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list &&\ - apt update &&\ - apt install -y google-chrome-stable firefox-esr fi diff --git a/image/discourse_test/Dockerfile b/image/discourse_test/Dockerfile index 3558705..48ea2e7 100644 --- a/image/discourse_test/Dockerfile +++ b/image/discourse_test/Dockerfile @@ -17,10 +17,8 @@ RUN chown -R discourse . &&\ FROM base AS with_browsers -ADD install-chrome /tmp/install-chrome -RUN /tmp/install-chrome &&\ - apt update &&\ - apt install -y libgconf-2-4 libxss1 firefox-esr &&\ +RUN apt update &&\ + apt install -y libgconf-2-4 libxss1 firefox-esr chromium-driver &&\ cd /tmp && wget -q "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US" -O firefox.tar.bz2 &&\ tar xjvf firefox.tar.bz2 && mv /tmp/firefox /opt/firefox-evergreen &&\ apt clean @@ -36,4 +34,4 @@ RUN cd /var/www/discourse && sudo -E -u discourse -H bundle exec rake plugin:ins LOAD_PLUGINS=1 sudo -E -u discourse -H bundle exec rake plugin:install_all_gems &&\ sudo -E -u discourse -H bundle exec ruby script/install_minio_binaries.rb -ENTRYPOINT ["sudo", "-E", "-u", "discourse", "-H", "ruby", "script/docker_test.rb"] \ No newline at end of file +ENTRYPOINT ["sudo", "-E", "-u", "discourse", "-H", "ruby", "script/docker_test.rb"] diff --git a/image/discourse_test/install-chrome b/image/discourse_test/install-chrome deleted file mode 100755 index b6e559e..0000000 --- a/image/discourse_test/install-chrome +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -e - -# https://googlechromelabs.github.io/chrome-for-testing/ doesn't provide linux/arm64 binaries for chrome or chromedriver -# yet. Therefore on arm64, we install chromium instead of chrome and install a chromedriver for linux/arm64 from -# https://github.com/electron/electron/releases/. -# -# On the current debian Chromium 120.0.6099.224 is installed so we have to install a chromedriver that is of the same version. -if [ "$(dpkg --print-architecture)" = "arm64" ]; then - apt update && apt install -y chromium unzip &&\ - wget -q -O /tmp/chromedriver.zip https://github.com/electron/electron/releases/download/v28.2.2/chromedriver-v28.2.2-linux-arm64.zip &&\ - unzip /tmp/chromedriver.zip -d /tmp/chromedriver &&\ - mv /tmp/chromedriver/chromedriver /usr/bin &&\ - rm -rf /tmp/chromedriver /tmp/chromedriver.zip -else - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - &&\ - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list &&\ - apt update &&\ - apt install -y google-chrome-stable -fi -- 2.25.1