Update Dockerfile
Browse files- Dockerfile +38 -57
Dockerfile
CHANGED
|
@@ -1,62 +1,43 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM python:3.
|
| 3 |
-
|
| 4 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
-
|
| 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 |
-
#
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
-
# Expose port
|
| 59 |
-
EXPOSE
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
CMD ["uvicorn", "
|
|
|
|
| 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 perchance_server_with_pyvirtualdisplay.py ./perchance_server_with_pyvirtualdisplay.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"]
|