Installed google-chrome missing lots shared libs

I followed Installing Headless chromium w/o docker - #5 to install chrome on the server as i am trying to use webdriver:

service = Service(ChromeDriverManager().install())
self.driver = webdriver.Chrome(service=service, options=options)

I am using docker, so i have this in my dockerfile:

COPY install_chrome.sh /opt/render/project/install_chrome.sh
RUN chmod +x /opt/render/project/install_chrome.sh
RUN /opt/render/project/install_chrome.sh
ENV PATH="${PATH}:/opt/render/project/.render/chrome/opt/google/chrome"

And here is the install_chrome.sh:

set -o errexit

if ! command -v google-chrome-stable &> /dev/null; then
    echo "Installing Google Chrome stable..."
    apt-get update
    apt-get install -y wget libglib2.0-0 libnss3 libfontconfig1 libfreetype6 libappindicator1 libxss1 libasound2 libatk-bridge2.0-0 libdrm2 libgbm1 libxcursor1 libxrandr2 libxcomposite1 libxdamage1 libxss1 libxtst6 libpango-1.0-0 libcairo2 libdbus-1-3 libdbus-glib-1-2 libpulse0 libatspi2.0-0 libgtk-3-0 libnss3-tools libxkbcommon0Preformatted text

    STORAGE_DIR=/opt/render/project/.render

    if [[ ! -d $STORAGE_DIR/chrome ]]; then
        echo "...Downloading Chrome"
        mkdir -p $STORAGE_DIR/chrome
        cd $STORAGE_DIR/chrome
        wget -P ./ https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
        dpkg -x ./google-chrome-stable_current_amd64.deb $STORAGE_DIR/chrome
        rm ./google-chrome-stable_current_amd64.deb
        cd /universitygpt # Make sure we return to where we were
    else
        echo "...Using Chrome from cache"
    fi
else
    echo "Google Chrome stable is already installed"
fi

I am just keep adding those libs to apt-get install line every time i deploy and had error on logs, but still getting errors. Is there anything wrong with what i am doing here? Is there a better way to install chrome.

Hi there,

Those instructions are for use when not using Docker (using a native runtime). Caching works differently between native runtime builds and docker builds, and this will not cache Chrome in a docker runtime. Seeing your base docker image doesn’t include Chrome, it will be installed every time.

You could have your own curated base image, including Chrome, and host it on Docker Hub (or GitHub/GitLabs image repos). This will mean you don’t need to download and install it on every Render build.

Another option could be to use selenium/standalone-chrome as a base image, as I believe this also includes Python.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.