AdarshJi commited on
Commit
6a20ac1
·
verified ·
1 Parent(s): f199878

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -34
Dockerfile CHANGED
@@ -1,59 +1,62 @@
1
- # Dockerfile (run non-headless Chrome via Xvfb)
2
- FROM python:3.12-slim
3
-
4
- ENV PYTHONDONTWRITEBYTECODE=1 \
5
- PYTHONUNBUFFERED=1 \
6
- PORT=7860 \
7
- ZD_HEADLESS=false \
8
- NO_INITIAL_FETCH=false
9
 
 
 
10
  WORKDIR /app
11
 
12
- # Install system deps including Xvfb and Chromium
13
- RUN apt-get update && apt-get install -y --no-install-recommends \
 
14
  ca-certificates \
15
- curl \
16
  wget \
 
17
  unzip \
18
  xvfb \
19
- dbus-x11 \
20
  x11-utils \
21
  fonts-liberation \
22
  libnss3 \
23
  libxss1 \
24
  libasound2 \
25
  libatk1.0-0 \
 
26
  libcups2 \
27
  libx11-xcb1 \
28
  libxcomposite1 \
29
  libxdamage1 \
30
  libxrandr2 \
31
  libgbm1 \
32
- libgtk-3-0 \
 
 
33
  libxshmfence1 \
34
- procps \
35
- build-essential \
36
- && rm -rf /var/lib/apt/lists/*
37
-
38
- # Install Chromium (Debian package). If that fails on some base images,
39
- # adjust package name to chromium-browser.
40
- RUN apt-get update && apt-get install -y --no-install-recommends chromium \
41
- || true && rm -rf /var/lib/apt/lists/*
42
-
43
- ENV CHROME_BIN=/usr/bin/chromium
44
-
45
- # python deps
 
 
 
46
  COPY requirements.txt /app/requirements.txt
47
- RUN python -m pip install --upgrade pip setuptools wheel \
48
- && pip --no-cache-dir install -r /app/requirements.txt
49
 
50
- # app files
51
- COPY . /app
52
 
53
- # start script
54
- COPY start.sh /app/start.sh
55
- RUN chmod +x /app/start.sh
56
 
57
- EXPOSE ${PORT}
 
58
 
59
- CMD ["sh", "-c", "/app/start.sh"]
 
 
1
+ # Dockerfile
2
+ FROM python:3.9-slim
 
 
 
 
 
 
3
 
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+ ENV CHROME_BIN=/usr/bin/google-chrome-stable
6
  WORKDIR /app
7
 
8
+ # Install system packages needed for Chrome, Xvfb and general runtime.
9
+ RUN apt-get update \
10
+ && apt-get install -y --no-install-recommends \
11
  ca-certificates \
 
12
  wget \
13
+ gnupg \
14
  unzip \
15
  xvfb \
 
16
  x11-utils \
17
  fonts-liberation \
18
  libnss3 \
19
  libxss1 \
20
  libasound2 \
21
  libatk1.0-0 \
22
+ libatk-bridge2.0-0 \
23
  libcups2 \
24
  libx11-xcb1 \
25
  libxcomposite1 \
26
  libxdamage1 \
27
  libxrandr2 \
28
  libgbm1 \
29
+ xdg-utils \
30
+ libxrender1 \
31
+ libxext6 \
32
  libxshmfence1 \
33
+ libglib2.0-0 \
34
+ libdbus-1-3 \
35
+ libdrm2 \
36
+ && rm -rf /var/lib/apt/lists/*
37
+
38
+ # Add Google's signing key and install google-chrome-stable
39
+ RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub \
40
+ | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
41
+ && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
42
+ > /etc/apt/sources.list.d/google-chrome.list \
43
+ && apt-get update \
44
+ && apt-get install -y --no-install-recommends google-chrome-stable \
45
+ && rm -rf /var/lib/apt/lists/*
46
+
47
+ # Copy requirements and install python packages
48
  COPY requirements.txt /app/requirements.txt
49
+ RUN pip install --no-cache-dir --upgrade pip \
50
+ && pip install --no-cache-dir -r /app/requirements.txt
51
 
52
+ # Install Playwright browsers (chromium) with dependencies
53
+ RUN python -m playwright install --with-deps chromium
54
 
55
+ # Copy application code
56
+ COPY . /app
 
57
 
58
+ # Expose port
59
+ EXPOSE 7860
60
 
61
+ # Run the app (runs as root for simplicity)
62
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860" , "--workers" , "3", "--log-level" ,"info"]