heroku / heroku-buildpack-chrome-for-testing

Heroku Buildpack that installs Chrome for Testing
19 stars 4 forks source link

Issue with Installing Chrome and ChromeDriver in Docker on Heroku #24

Closed nicolascopernic closed 3 months ago

nicolascopernic commented 3 months ago

Hi,

I am reaching out to seek assistance with an issue I've encountered while attempting to install Google Chrome and ChromeDriver in a Dockerized environment on Heroku using the heroku-community/chrome-for-testing buildpack.

I am running a Python application that requires headless browsing capabilities provided by Selenium. For this, I need both Google Chrome and ChromeDriver to be installed and accessible within my Docker container on Heroku.

Despite following the installation instructions and using the heroku-community/chrome-for-testing buildpack, I am unable to locate the Chrome binary within the Docker container. Here are the steps I have taken and the issues encountered:

1. Configured Buildpacks:

heroku buildpacks -a my-app

Output:

1. heroku-community/chrome-for-testing
2. heroku/python

2. Dockerfile:

FROM python:3.11

# Install dependencies
RUN apt-get update && apt-get install -y \
    ffmpeg libsm6 libxext6 wget unzip gnupg libglib2.0-0 libnss3 libgconf-2-4 libfontconfig1 \
    && rm -rf /var/lib/apt/lists/*

# Download and install Google Chrome
RUN wget -O /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
    && apt-get update \
    && apt-get install -y /tmp/google-chrome-stable_current_amd64.deb \
    && rm /tmp/google-chrome-stable_current_amd64.deb

# Ensure Chrome is in the PATH
RUN ln -s /usr/bin/google-chrome /usr/local/bin/google-chrome

# Download and install ChromeDriver
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` \
    && wget -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip \
    && unzip /tmp/chromedriver.zip -d /usr/local/bin/ \
    && rm /tmp/chromedriver.zip

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./ /code/

CMD ["bash"]

3. Verification:

After deploying the application, I ran the following commands to verify the installation:

heroku run bash -a my-app
# In the Heroku bash shell
which chrome
which chromedriver

Output:

/usr/local/bin/chromedriver

Unfortunately, which chrome returns nothing, indicating that Chrome is not installed correctly or not accessible in the PATH.

I have checked the logs for any errors during the installation process, but none were apparent. The ChromeDriver binary is installed and accessible, but the Chrome binary is not.

Could you please provide guidance or additional steps to ensure that Google Chrome is installed and accessible within my Docker container on Heroku? Any insights or suggestions would be greatly appreciated.

Thank you for your time and assistance.

Best regards, Nicolas

edmorley commented 3 months ago

Heroku's container stack is completely separate from buildpacks. If you use the container stack, no buildpacks are run, and instead the build is performed using your Dockerfile.

See: https://devcenter.heroku.com/articles/build-docker-images-heroku-yml