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.