Hi everyone,
I’m running into a head-scratching issue with my Flask-based Chrome extension project deployed on Render. I created this extension to scrape images from my clients’ old websites (with their permission).
Locally everything runs fine, but when deployed on Render I get the following error when calling the /scrape endpoint:
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /usr/bin/google-chrome
I believe this is because the deployed container is missing Google Chrome. Below are the relevant portions of my files:
Dockerfile.txt
Use Python as the base image
FROM python:3.9
Install FFmpeg (needed for pydub)
RUN apt-get update && apt-get install -y ffmpeg
Set the working directory
WORKDIR /app
Copy all project files into the container
COPY . .
Install Python dependencies
RUN pip install -r requirements.txt
Expose the Flask port
EXPOSE 5000
Start the server using gunicorn
CMD [“gunicorn”, “-b”, “0.0.0.0:5000”, “server:app”]
requirements.txt
Flask
requests
selenium
webdriver-manager
pydub
flask-cors
gunicorn
Relevant Portion of server.py
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
…
chrome_options = Options()
chrome_options.binary_location = “/usr/bin/google-chrome”
chrome_options.add_argument(“–headless”)
chrome_options.add_argument(“–disable-gpu”)
chrome_options.add_argument(“–no-sandbox”)
chrome_options.add_argument(“–disable-dev-shm-usage”)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
My server code sets chrome_options.binary_location = "/usr/bin/google-chrome"
, but my Dockerfile only installs FFmpeg and doesn’t install Google Chrome. Is installing Chrome in the Dockerfile (and possibly creating a symlink) the best approach on Render, or is there a better practice?
Any advice or suggestions would be greatly appreciated.
Thanks in advance for your help!