File size: 1,701 Bytes
45eb591 562b2e9 ef0912e 45eb591 a67cd68 ef0912e 83f7f01 45eb591 562b2e9 83f7f01 562b2e9 45eb591 a67cd68 45eb591 562b2e9 83f7f01 45eb591 562b2e9 45eb591 562b2e9 83f7f01 45eb591 ef0912e 10d110b 83f7f01 57f70ae 562b2e9 83f7f01 45eb591 83f7f01 ef0912e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # Dockerfile
FROM python:3.9-slim
ENV DEBIAN_FRONTEND=noninteractive
ENV CHROME_BIN=/usr/bin/google-chrome-stable
WORKDIR /app
# Install system packages needed for Chrome, Xvfb and general runtime.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
wget \
gnupg \
unzip \
xvfb \
x11-utils \
fonts-liberation \
libnss3 \
libxss1 \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
xdg-utils \
libxrender1 \
libxext6 \
libxshmfence1 \
libglib2.0-0 \
libdbus-1-3 \
libdrm2 \
&& rm -rf /var/lib/apt/lists/*
# Add Google's signing key and install google-chrome-stable
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub \
| gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install python packages
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r /app/requirements.txt
# Install Playwright browsers (chromium) with dependencies
RUN python -m playwright install --with-deps chromium
# Copy application code
COPY . /app
# Expose port
EXPOSE 7860
# Run the app (runs as root for simplicity)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |