Skip to content

Commit

Permalink
Docker: Install Firefox from multiple package types (#2547)
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 authored Jan 1, 2025
1 parent 3902799 commit 75c70ea
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CURRENT_PLATFORM := $(shell if [ `arch` = "aarch64" ] || [ `arch` = "arm64" ]; t
PLATFORMS := $(or $(PLATFORMS),$(shell echo $$PLATFORMS),$(CURRENT_PLATFORM))
SEL_PASSWD := $(or $(SEL_PASSWD),$(SEL_PASSWD),secret)
CHROMIUM_VERSION := $(or $(CHROMIUM_VERSION),$(CHROMIUM_VERSION),latest)
FIREFOX_DOWNLOAD_URL := $(or $(FIREFOX_DOWNLOAD_URL),$(FIREFOX_DOWNLOAD_URL),https://download-installer.cdn.mozilla.net/pub/firefox/nightly/2024/10/2024-10-28-09-56-35-mozilla-central/firefox-133.0a1.en-US.linux-aarch64.tar.bz2)
FIREFOX_DOWNLOAD_URL := $(or $(FIREFOX_DOWNLOAD_URL),$(FIREFOX_DOWNLOAD_URL),https://download-installer.cdn.mozilla.net/pub/firefox/nightly/2024/10/2024-10-28-09-56-35-mozilla-central/firefox-133.0a1.en-US.linux-aarch64.deb)
SBOM_OUTPUT := $(or $(SBOM_OUTPUT),$(SBOM_OUTPUT),package_versions.txt)
KEDA_TAG_PREV_VERSION := $(or $(KEDA_TAG_PREV_VERSION),$(KEDA_TAG_PREV_VERSION),2.16.1-selenium-grid)
KEDA_CORE_VERSION := $(or $(KEDA_CORE_VERSION),$(KEDA_CORE_VERSION),2.16.1)
Expand Down
23 changes: 8 additions & 15 deletions NodeFirefox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ USER root
#============================================
# Firefox cleanup script and supervisord file
#============================================
COPY --chown="${SEL_UID}:${SEL_GID}" firefox-cleanup.sh get_lang_package.sh install-firefox-apt.sh /opt/bin/
COPY --chown="${SEL_UID}:${SEL_GID}" firefox-cleanup.sh get_lang_package.sh install-firefox-apt.sh install-firefox-package.sh /opt/bin/
COPY --chown="${SEL_UID}:${SEL_GID}" firefox-cleanup.conf /etc/supervisor/conf.d/firefox-cleanup.conf
RUN chmod +x /opt/bin/firefox-cleanup.sh /opt/bin/get_lang_package.sh /opt/bin/install-firefox-apt.sh
RUN chmod +x /opt/bin/firefox-cleanup.sh /opt/bin/get_lang_package.sh /opt/bin/install-firefox-apt.sh /opt/bin/install-firefox-package.sh

#=========
# Firefox
#=========
ARG FIREFOX_VERSION=latest
ARG FIREFOX_DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os=linux64-aarch64&lang=en-US"
ARG FIREFOX_DOWNLOAD_URL=""
RUN apt-get update -qqy && \
if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
if [ $FIREFOX_VERSION = "latest" ] || [ $FIREFOX_VERSION = "beta-latest" ] || [ $FIREFOX_VERSION = "nightly-latest" ] || [ $FIREFOX_VERSION = "devedition-latest" ] || [ $FIREFOX_VERSION = "esr-latest" ]; then \
FIREFOX_DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-$FIREFOX_VERSION-ssl&os=linux64&lang=en-US"; \
/opt/bin/install-firefox-apt.sh \
&& FIREFOX_VERSION=$(echo "-$FIREFOX_VERSION" | sed 's/-latest//') \
&& apt install -y firefox$FIREFOX_VERSION \
Expand All @@ -31,10 +30,11 @@ RUN apt-get update -qqy && \
ln -fs $(which firefox$FIREFOX_VERSION) /usr/bin/firefox ; \
fi ; \
else \
FIREFOX_DOWNLOAD_URL="https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2" ; \
FIREFOX_DOWNLOAD_URL="https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.deb" ; \
fi \
else \
if [ $FIREFOX_VERSION = "nightly-latest" ]; then \
if [ $FIREFOX_VERSION = "latest" ]; then \
FIREFOX_VERSION="nightly-latest" ; \
/opt/bin/install-firefox-apt.sh \
&& FIREFOX_VERSION=$(echo "-$FIREFOX_VERSION" | sed 's/-latest//') \
&& apt install -y firefox$FIREFOX_VERSION \
Expand All @@ -46,15 +46,8 @@ RUN apt-get update -qqy && \
FIREFOX_DOWNLOAD_URL="${FIREFOX_DOWNLOAD_URL}" ; \
fi ; \
fi && \
if [ "$INSTALL_VIA_APT" != "true" ]; then \
apt-get -qqy --no-install-recommends install libavcodec-extra libgtk-3-dev libdbus-glib-1-dev xz-utils \
&& wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \
&& rm -rf /opt/firefox \
&& tar -C /opt -xjf /tmp/firefox.tar.bz2 || (mv /tmp/firefox.tar.bz2 /tmp/firefox.tar.xz && tar -C /opt -xJf /tmp/firefox.tar.xz) \
&& rm -rf /tmp/firefox.tar.bz2 /tmp/firefox.tar.xz \
&& mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \
&& mkdir -p /opt/firefox-$FIREFOX_VERSION/distribution/extensions \
&& ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefox ; \
if [ "${INSTALL_VIA_APT}" != "true" ]; then \
/opt/bin/install-firefox-package.sh "${FIREFOX_DOWNLOAD_URL}" "${FIREFOX_VERSION}" ; \
fi \
# Download the language pack for Firefox
&& /opt/bin/get_lang_package.sh \
Expand Down
44 changes: 44 additions & 0 deletions NodeFirefox/install-firefox-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

FIREFOX_DOWNLOAD_URL=$1
FIREFOX_VERSION=$2

function extract_package_tar_bz2() {
sudo rm -rf /opt/firefox
tar -C /opt -xjf /tmp/firefox.tar.bz2
rm -rf /tmp/firefox.tar.bz2
}

function extract_package_tar_xz() {
sudo rm -rf /opt/firefox
tar -C /opt -xJf /tmp/firefox.tar.xz
rm -rf /tmp/firefox.tar.xz
}

function install_package() {
sudo apt-get -qqy --no-install-recommends install libavcodec-extra libgtk-3-dev libdbus-glib-1-dev xz-utils
echo "Installing Firefox from package..."
sudo mv /opt/firefox "/opt/firefox-${FIREFOX_VERSION}"
sudo mkdir -p "/opt/firefox-${FIREFOX_VERSION}/distribution/extensions"
sudo ln -fs "/opt/firefox-${FIREFOX_VERSION}/firefox" /usr/bin/firefox
}

if [[ "${FIREFOX_DOWNLOAD_URL}" == *".deb"* ]]; then
echo "Downloading Firefox from ${FIREFOX_DOWNLOAD_URL}"
wget -q -O /tmp/firefox.deb "${FIREFOX_DOWNLOAD_URL}"
echo "Installing Firefox from deb package..."
sudo apt-get install -y --allow-downgrades -f /tmp/firefox.deb
rm -f /tmp/firefox.deb
elif [[ "${FIREFOX_DOWNLOAD_URL}" == *".tar.bz2"* ]]; then
echo "Downloading Firefox from ${FIREFOX_DOWNLOAD_URL}"
wget -q -O /tmp/firefox.tar.bz2 "${FIREFOX_DOWNLOAD_URL}"
extract_package_tar_bz2
install_package
rm -f /tmp/firefox.tar.bz2
elif [[ "${FIREFOX_DOWNLOAD_URL}" == *".tar.xz"* ]]; then
echo "Downloading Firefox from ${FIREFOX_DOWNLOAD_URL}"
wget -q -O /tmp/firefox.tar.xz "${FIREFOX_DOWNLOAD_URL}"
extract_package_tar_xz
install_package
rm -f /tmp/firefox.tar.xz
fi

0 comments on commit 75c70ea

Please sign in to comment.