DOCKERIZING SELENIUM PROJECT

Viewed 23

i had created a selenium project for webScraping.

i am having troubles when taking it to another machine so i'm trying to dockerize it.

i have watched some tutorials but i am really unsure of my steps or even if it's the proper way to do it ; it's my first time using docker.

i want to use python3.6.9 and chromedriver 90.0.4430.212

i have created some additional files in my project directory :

Dockerfile   docker-compose.yml   requirements.txt

the Dockerfile contains:

FROM python:3.6.9

ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

RUN mkdir /app
COPY ./app /app
WORKDIR /app

the docker-compose.yml contains:

version: '3'

services:
  selenium:
    image: selenium/standalone-chrome
    ports:
    - 4444:4444
    restart: always

  apps:
    build:
      context: .
    volumes:
     - ./app:/app
    command: sh -c "python3 run.py"
    depends_on:
     - selenium 

and the requirements.txt contains :

selenium==3.141.0

i have also added the following code :


class Booking(webdriver.Remote("http://localhost:4444/wd/hub",desired_capabilities=DesiredCapabilities.CHROME)):

    def __init__(self, closed=False, enablePohotos=False):
        
    def __exit__(self, exc_type, exc_val, exc_tb):

i also put all the files of the script in a directory named /app

i have other functions but they're not relevant to my question.

i someone can help i really appreciate it .

0 Answers
Related