AdarshJi commited on
Commit
680e237
·
verified ·
1 Parent(s): a108652

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -31
Dockerfile CHANGED
@@ -1,43 +1,42 @@
1
- # Use a slim Python base
2
- FROM python:3.11-slim
3
 
4
  ENV DEBIAN_FRONTEND=noninteractive \
5
  PYTHONUNBUFFERED=1 \
6
  TZ=Etc/UTC \
7
  PORT=7860 \
8
- # Keep headless = false as you requested; server will start a virtual display if needed
9
  ZD_HEADLESS=false \
10
- NO_INITIAL_FETCH=0 \
11
- # Default chromium path (used by some tools). Update if needed.
12
- CHROME_PATH=/usr/bin/chromium
13
-
14
- # Install runtime deps including Xvfb and Chromium (and fonts / libs)
15
- RUN apt-get update && apt-get install -y --no-install-recommends \
16
- ca-certificates \
17
- wget \
18
- curl \
19
- gnupg \
20
- xvfb \
21
- chromium \
22
- chromium-driver \
23
- libxrender1 libxext6 libxi6 libxtst6 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
24
- libgtk-3-0 libnss3 libasound2 libatk1.0-0 libatk-bridge2.0-0 \
25
- fonts-liberation fonts-dejavu-core \
26
- && rm -rf /var/lib/apt/lists/*
27
-
28
- # Create app dir
29
  WORKDIR /app
30
 
31
- # Copy requirements and server file
32
- COPY requirements.txt ./requirements.txt
33
- COPY server.py ./server.py
 
 
34
 
35
- # Install Python deps
36
- RUN python -m pip install --upgrade pip setuptools wheel \
37
- && pip install --no-cache-dir -r requirements.txt
38
 
39
- # Expose port used by uvicorn
40
  EXPOSE ${PORT}
41
 
42
- # Default command to run the FastAPI app via uvicorn
43
- CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860", "--loop", "asyncio", "--workers", "1"]
 
 
 
 
1
+ # Dockerfile (use alongside perchance_server_with_pyvirtualdisplay.py and entrypoint.sh)
2
+ FROM ubuntu:22.04
3
 
4
  ENV DEBIAN_FRONTEND=noninteractive \
5
  PYTHONUNBUFFERED=1 \
6
  TZ=Etc/UTC \
7
  PORT=7860 \
 
8
  ZD_HEADLESS=false \
9
+ USE_VIRTUAL_DISPLAY=true \
10
+ NO_INITIAL_FETCH=0
11
+
12
+ # Install system deps (Xvfb, fonts, curl, unzip, etc.)
13
+ RUN apt-get update \
14
+ && apt-get install -y --no-install-recommends \
15
+ python3 python3-pip python3-venv python3-distutils \
16
+ ca-certificates wget curl gnupg unzip \
17
+ xvfb x11-xkb-utils xauth xdg-utils \
18
+ libnss3 libxss1 libasound2 libatk1.0-0 libatk-bridge2.0-0 \
19
+ libgtk-3-0 libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
20
+ fonts-liberation fonts-dejavu-core fonts-noto-cjk \
21
+ tzdata \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
 
 
 
 
24
  WORKDIR /app
25
 
26
+ # Copy project files
27
+ COPY server.py /app/server.py
28
+ COPY requirements.txt /app/requirements.txt
29
+ COPY entrypoint.sh /app/entrypoint.sh
30
+ RUN chmod +x /app/entrypoint.sh
31
 
32
+ # Install python deps
33
+ RUN python3 -m pip install --upgrade pip setuptools wheel \
34
+ && pip install --no-cache-dir -r /app/requirements.txt
35
 
 
36
  EXPOSE ${PORT}
37
 
38
+ # Health check (simple)
39
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=15s --retries=3 \
40
+ CMD curl -fsS http://127.0.0.1:${PORT}/health || exit 1
41
+
42
+ ENTRYPOINT ["/app/entrypoint.sh"]