AdityaAdaki commited on
Commit
406067c
·
1 Parent(s): 96cbe01

Update Docker configuration to use Chrome instead of Chromium

Browse files
Files changed (2) hide show
  1. Dockerfile +19 -3
  2. main.py +1 -1
Dockerfile CHANGED
@@ -5,14 +5,27 @@ FROM python:3.9
5
 
6
  WORKDIR /app
7
 
8
- # Install system dependencies
9
  RUN apt-get update && apt-get install -y \
10
- chromium \
11
- chromium-driver \
12
  libgl1-mesa-glx \
13
  libglib2.0-0 \
 
 
 
 
14
  && rm -rf /var/lib/apt/lists/*
15
 
 
 
 
 
 
 
 
 
 
16
  # Create a non-root user
17
  RUN useradd -m -u 1000 user
18
  USER user
@@ -28,5 +41,8 @@ COPY --chown=user . .
28
  ENV PATH="/home/user/.local/bin:${PATH}"
29
  ENV PYTHONPATH="/home/user/.local/lib/python3.9/site-packages:${PYTHONPATH}"
30
 
 
 
 
31
  # Run the application
32
  CMD ["python", "main.py"]
 
5
 
6
  WORKDIR /app
7
 
8
+ # Install system dependencies and Chrome
9
  RUN apt-get update && apt-get install -y \
10
+ wget \
11
+ gnupg2 \
12
  libgl1-mesa-glx \
13
  libglib2.0-0 \
14
+ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
15
+ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
16
+ && apt-get update \
17
+ && apt-get install -y google-chrome-stable \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
+ # Install ChromeDriver
21
+ RUN CHROME_VERSION=$(google-chrome --version | awk '{ print $3 }' | cut -d'.' -f1) \
22
+ && wget -q "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}" -O - | xargs -I {} \
23
+ wget -q "https://chromedriver.storage.googleapis.com/{}/chromedriver_linux64.zip" \
24
+ && unzip chromedriver_linux64.zip \
25
+ && mv chromedriver /usr/local/bin/ \
26
+ && chmod +x /usr/local/bin/chromedriver \
27
+ && rm chromedriver_linux64.zip
28
+
29
  # Create a non-root user
30
  RUN useradd -m -u 1000 user
31
  USER user
 
41
  ENV PATH="/home/user/.local/bin:${PATH}"
42
  ENV PYTHONPATH="/home/user/.local/lib/python3.9/site-packages:${PYTHONPATH}"
43
 
44
+ # Update the chrome binary location in the code
45
+ ENV CHROME_BINARY_LOCATION="/usr/bin/google-chrome"
46
+
47
  # Run the application
48
  CMD ["python", "main.py"]
main.py CHANGED
@@ -251,7 +251,7 @@ def setup_webdriver():
251
  chrome_options.add_argument('--headless')
252
  chrome_options.add_argument('--no-sandbox')
253
  chrome_options.add_argument('--disable-dev-shm-usage')
254
- chrome_options.binary_location = '/usr/bin/chromium'
255
  return webdriver.Chrome(options=chrome_options)
256
 
257
  def create_polygon_mask(image_size, points):
 
251
  chrome_options.add_argument('--headless')
252
  chrome_options.add_argument('--no-sandbox')
253
  chrome_options.add_argument('--disable-dev-shm-usage')
254
+ chrome_options.binary_location = os.getenv('CHROME_BINARY_LOCATION', '/usr/bin/google-chrome')
255
  return webdriver.Chrome(options=chrome_options)
256
 
257
  def create_polygon_mask(image_size, points):