From 68d150d372db5b44f2507fe496f7e6bab36ec59d Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 21 Mar 2024 07:46:57 +0800 Subject: [PATCH] Revert "Use Chromium instead of Chrome (#782)" (#783) This reverts commit e6ffa64d9d7622327b134c8397f59edf832e4299. We need to fix the various Chrome assumptions in Discourse core. --- 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, 35 insertions(+), 5 deletions(-) create mode 100755 image/discourse_test/install-chrome diff --git a/image/discourse_dev/Dockerfile b/image/discourse_dev/Dockerfile index 26e61d5..65e79be 100644 --- a/image/discourse_dev/Dockerfile +++ b/image/discourse_dev/Dockerfile @@ -39,7 +39,6 @@ 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 93dba2d..2cf6f74 100755 --- a/image/discourse_dev/install-selenium +++ b/image/discourse_dev/install-selenium @@ -1,9 +1,13 @@ #!/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 -# (yet). So we have to compile it ourselves. +# either (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 @@ -16,4 +20,9 @@ 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 48ea2e7..3558705 100644 --- a/image/discourse_test/Dockerfile +++ b/image/discourse_test/Dockerfile @@ -17,8 +17,10 @@ RUN chown -R discourse . &&\ FROM base AS with_browsers -RUN apt update &&\ - apt install -y libgconf-2-4 libxss1 firefox-esr chromium-driver &&\ +ADD install-chrome /tmp/install-chrome +RUN /tmp/install-chrome &&\ + apt update &&\ + apt install -y libgconf-2-4 libxss1 firefox-esr &&\ 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 @@ -34,4 +36,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"] +ENTRYPOINT ["sudo", "-E", "-u", "discourse", "-H", "ruby", "script/docker_test.rb"] \ No newline at end of file diff --git a/image/discourse_test/install-chrome b/image/discourse_test/install-chrome new file mode 100755 index 0000000..b6e559e --- /dev/null +++ b/image/discourse_test/install-chrome @@ -0,0 +1,20 @@ +#!/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