hamza2923 commited on
Commit
8f456ef
·
verified ·
1 Parent(s): 13ab14a

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +22 -39
dockerfile CHANGED
@@ -1,59 +1,42 @@
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 \
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
- --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"]
 
 
1
  FROM python:3.10-slim
2
 
3
  # Set environment variables
4
  ENV PYTHONDONTWRITEBYTECODE 1
5
  ENV PYTHONUNBUFFERED 1
6
 
 
7
  WORKDIR /app
8
 
9
+ # Install dependencies
10
  RUN apt-get update && apt-get install -y \
11
+ wget curl unzip gnupg ca-certificates fonts-liberation \
12
+ libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 \
13
+ libcups2 libdbus-1-3 libgdk-pixbuf2.0-0 libnspr4 libnss3 \
14
+ libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 xdg-utils \
15
+ --no-install-recommends && rm -rf /var/lib/apt/lists/*
16
+
17
+ # Install Google Chrome (stable)
18
+ RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
19
+ dpkg -i google-chrome-stable_current_amd64.deb || apt-get -fy install && \
20
+ rm google-chrome-stable_current_amd64.deb
21
+
22
+ # Get Chrome version and install matching ChromeDriver
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') && \
24
+ echo "Using Chrome version: $CHROME_VERSION" && \
25
+ wget -q -O /tmp/chromedriver.zip "https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip" && \
26
  unzip /tmp/chromedriver.zip -d /tmp/ && \
27
  mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && \
28
  chmod +x /usr/local/bin/chromedriver && \
29
  rm -rf /tmp/chromedriver*
30
 
 
 
 
31
  # Install Python dependencies
32
+ COPY requirements.txt .
33
+ RUN pip install --no-cache-dir -r requirements.txt
34
+
35
+ # Copy app
36
+ COPY . /app
37
 
38
+ # Expose FastAPI port
39
  EXPOSE 7860
40
 
41
+ # Run app
42
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]