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

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +32 -29
dockerfile CHANGED
@@ -1,11 +1,20 @@
1
- FROM python:3.9-slim
 
 
 
 
 
 
 
 
2
 
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 \
@@ -21,36 +30,30 @@ RUN apt-get update && apt-get install -y \
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"]
 
1
+ # Use an official Python base image
2
+ FROM python:3.10-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE 1
6
+ ENV PYTHONUNBUFFERED 1
7
+
8
+ # Set work directory
9
+ WORKDIR /app
10
 
11
  # Install system dependencies
12
  RUN apt-get update && apt-get install -y \
13
  wget \
 
14
  unzip \
15
+ curl \
16
  gnupg \
17
+ ca-certificates \
18
  fonts-liberation \
19
  libappindicator3-1 \
20
  libasound2 \
 
30
  libxdamage1 \
31
  libxrandr2 \
32
  xdg-utils \
33
+ --no-install-recommends
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ # Install Google Chrome
36
+ RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
37
+ && dpkg -i google-chrome-stable_current_amd64.deb || apt-get -fy install \
38
+ && rm google-chrome-stable_current_amd64.deb
39
+
40
+ # Install ChromeDriver (matching the installed Chrome version)
41
+ RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') && \
42
+ wget -q -O /tmp/chromedriver.zip https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip && \
43
+ unzip /tmp/chromedriver.zip -d /tmp/ && \
44
+ mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && \
45
+ chmod +x /usr/local/bin/chromedriver && \
46
+ rm -rf /tmp/chromedriver*
47
 
48
+ # Copy project files
49
  COPY . /app
 
50
 
51
+ # Install Python dependencies
52
+ RUN pip install --upgrade pip
53
+ RUN pip install -r requirements.txt
54
+
55
+ # Expose FastAPI default port
56
  EXPOSE 7860
57
 
58
+ # Run the application
59
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]