hamza2923 commited on
Commit
1cc4276
·
verified ·
1 Parent(s): bba5061

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +38 -53
dockerfile CHANGED
@@ -3,69 +3,54 @@ FROM python:3.9-slim
3
  # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  wget \
6
- gnupg \
7
- unzip \
8
  curl \
9
- libx11-6 \
 
 
 
 
 
 
 
 
 
 
10
  libnss3 \
11
- libgconf-2-4 \
12
- libfontconfig1 \
13
- libxrender1 \
14
  libx11-xcb1 \
15
  libxcomposite1 \
16
- libxcursor1 \
17
  libxdamage1 \
18
- libxi6 \
19
- libxtst6 \
20
  libxrandr2 \
21
- libasound2 \
22
- libatk1.0-0 \
23
- libatk-bridge2.0-0 \
24
- libcups2 \
25
- libpangocairo-1.0-0 \
26
  && rm -rf /var/lib/apt/lists/*
27
 
28
- # Add Google Chrome repository
29
- RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
30
- && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
31
-
32
- # Install Chrome, try specific version first, fall back to latest
33
- RUN apt-get update && \
34
- (apt-get install -y --no-install-recommends google-chrome-stable=136.0.7103.113-1 || \
35
- (echo "Specific Chrome version 136.0.7103.113-1 unavailable, installing latest" && \
36
- apt-get install -y --no-install-recommends google-chrome-stable)) && \
37
- rm -rf /var/lib/apt/lists/* \
38
- && google-chrome --version > /tmp/chrome-version.txt 2>&1 || echo "Chrome version check failed" > /tmp/chrome-version.txt
39
-
40
- # Get Chrome version and install matching ChromeDriver
41
- RUN CHROME_VERSION=$(cat /tmp/chrome-version.txt | grep -oP '\d+\.\d+\.\d+\.\d+' || echo "unknown") && \
42
- echo "Detected Chrome version: $CHROME_VERSION" && \
43
- if [ "$CHROME_VERSION" != "unknown" ]; then \
44
- wget -q -O /tmp/chromedriver.zip "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$CHROME_VERSION/linux64/chromedriver-linux64.zip" || \
45
- (echo "ChromeDriver download failed for $CHROME_VERSION, trying fallback" && \
46
- wget -q -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION%.*}/chromedriver_linux64.zip") && \
47
- unzip /tmp/chromedriver.zip -d /usr/bin/ && \
48
- mv /usr/bin/chromedriver-linux64/chromedriver /usr/bin/chromedriver && \
49
- chmod +x /usr/bin/chromedriver && \
50
- rm -rf /tmp/chromedriver.zip /usr/bin/chromedriver-linux64 && \
51
- chromedriver --version > /tmp/chromedriver-version.txt 2>&1 || echo "ChromeDriver version check failed" > /tmp/chromedriver-version.txt; \
52
- else \
53
- echo "Chrome not installed, skipping ChromeDriver" > /tmp/chromedriver-version.txt; \
54
- fi
55
-
56
- # Verify installations
57
- RUN echo "Checking installed files:" && \
58
- ls -l /usr/bin/google-chrome /usr/bin/chromedriver || echo "One or more binaries not found" && \
59
- cat /tmp/chrome-version.txt && \
60
- cat /tmp/chromedriver-version.txt
61
-
62
- WORKDIR /app
63
-
64
  COPY requirements.txt .
65
  RUN pip install --no-cache-dir -r requirements.txt
66
 
67
- COPY app.py .
 
 
68
 
69
- ENV PORT=7860
 
70
 
71
- CMD ["python", "app.py"]
 
 
3
  # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  wget \
 
 
6
  curl \
7
+ unzip \
8
+ gnupg \
9
+ fonts-liberation \
10
+ libappindicator3-1 \
11
+ libasound2 \
12
+ libatk-bridge2.0-0 \
13
+ libatk1.0-0 \
14
+ libcups2 \
15
+ libdbus-1-3 \
16
+ libgdk-pixbuf2.0-0 \
17
+ libnspr4 \
18
  libnss3 \
 
 
 
19
  libx11-xcb1 \
20
  libxcomposite1 \
 
21
  libxdamage1 \
 
 
22
  libxrandr2 \
23
+ xdg-utils \
24
+ libgbm-dev \
25
+ libgtk-3-0 \
26
+ libxshmfence-dev \
 
27
  && rm -rf /var/lib/apt/lists/*
28
 
29
+ # Install Google Chrome (latest stable)
30
+ RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
31
+ apt-get update && \
32
+ apt-get install -y ./google-chrome-stable_current_amd64.deb && \
33
+ rm google-chrome-stable_current_amd64.deb
34
+
35
+ # Install ChromeDriver (automatically detect version)
36
+ RUN CHROME_VERSION=$(google-chrome --version | sed 's/[^0-9.]*\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/') && \
37
+ CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}") && \
38
+ wget -q "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" && \
39
+ unzip chromedriver_linux64.zip && \
40
+ mv chromedriver /usr/bin/chromedriver && \
41
+ chmod +x /usr/bin/chromedriver && \
42
+ rm chromedriver_linux64.zip
43
+
44
+ # Install Python dependencies
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  COPY requirements.txt .
46
  RUN pip install --no-cache-dir -r requirements.txt
47
 
48
+ # Copy app code
49
+ COPY . /app
50
+ WORKDIR /app
51
 
52
+ # Expose port
53
+ EXPOSE 7860
54
 
55
+ # Run app
56
+ CMD ["python", "app.py"]