hamza2923 commited on
Commit
9ee640f
·
verified ·
1 Parent(s): 2988d6e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -14
Dockerfile CHANGED
@@ -1,27 +1,50 @@
 
1
  FROM python:3.10-slim
2
 
3
- ENV PYTHONDONTWRITEBYTECODE 1
4
- ENV PYTHONUNBUFFERED 1
 
5
 
 
6
  WORKDIR /app
7
 
8
- # Install dependencies
9
  RUN apt-get update && apt-get install -y \
10
- wget curl unzip gnupg ca-certificates fonts-liberation \
11
- libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 \
12
- libcups2 libdbus-1-3 libgdk-pixbuf2.0-0 libnspr4 libnss3 \
13
- libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 xdg-utils \
14
- --no-install-recommends && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  # Install Google Chrome stable
17
  RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
18
- dpkg -i google-chrome-stable_current_amd64.deb || apt-get -fy install && \
 
19
  rm google-chrome-stable_current_amd64.deb
20
 
21
- # Get Chrome major version
22
- RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+' | head -1) && \
23
- echo "Detected Chrome major version: $CHROME_VERSION" && \
24
- CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION") && \
25
  echo "Matching ChromeDriver version: $CHROMEDRIVER_VERSION" && \
26
  wget -q -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" && \
27
  unzip /tmp/chromedriver.zip -d /usr/local/bin/ && \
@@ -32,11 +55,14 @@ RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+' | head -1) && \
32
  COPY requirements.txt .
33
  RUN pip install --no-cache-dir -r requirements.txt
34
 
35
- # Copy app code
36
  COPY . /app
37
 
 
38
  EXPOSE 7860
39
 
 
40
  ENV PATH="/usr/local/bin:$PATH"
41
 
 
42
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use Python 3.10 slim base image
2
  FROM python:3.10-slim
3
 
4
+ # Environment variables to optimize Python
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
 
8
+ # Set working directory
9
  WORKDIR /app
10
 
11
+ # Install dependencies, including those required for Google Chrome
12
  RUN apt-get update && apt-get install -y \
13
+ wget \
14
+ curl \
15
+ unzip \
16
+ gnupg \
17
+ ca-certificates \
18
+ fonts-liberation \
19
+ libappindicator3-1 \
20
+ libasound2 \
21
+ libatk-bridge2.0-0 \
22
+ libatk1.0-0 \
23
+ libcups2 \
24
+ libdbus-1-3 \
25
+ libgdk-pixbuf2.0-0 \
26
+ libnspr4 \
27
+ libnss3 \
28
+ libx11-xcb1 \
29
+ libxcomposite1 \
30
+ libxdamage1 \
31
+ libxrandr2 \
32
+ xdg-utils \
33
+ libgbm1 \
34
+ libvulkan1 \
35
+ --no-install-recommends && \
36
+ rm -rf /var/lib/apt/lists/*
37
 
38
  # Install Google Chrome stable
39
  RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
40
+ dpkg -i google-chrome-stable_current_amd64.deb && \
41
+ apt-get -fy install && \
42
  rm google-chrome-stable_current_amd64.deb
43
 
44
+ # Install ChromeDriver
45
+ RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+' | head -1) && \
46
+ echo "Detected Chrome version: $CHROME_VERSION" && \
47
+ CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION%%.*}") && \
48
  echo "Matching ChromeDriver version: $CHROMEDRIVER_VERSION" && \
49
  wget -q -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" && \
50
  unzip /tmp/chromedriver.zip -d /usr/local/bin/ && \
 
55
  COPY requirements.txt .
56
  RUN pip install --no-cache-dir -r requirements.txt
57
 
58
+ # Copy application code
59
  COPY . /app
60
 
61
+ # Expose port for FastAPI
62
  EXPOSE 7860
63
 
64
+ # Ensure ChromeDriver is in PATH
65
  ENV PATH="/usr/local/bin:$PATH"
66
 
67
+ # Run FastAPI application
68
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]