pypyter / Dockerfile
triflix's picture
Update Dockerfile
509f4ab verified
# Use an official lightweight Python image.
FROM python:3.9-slim
# Set HOME to /root and define a custom PYPPETEER_HOME directory.
ENV HOME=/root
ENV PYPPETEER_HOME=/root/.pyppeteer
# Create the directory for Pyppeteer and set proper permissions.
RUN mkdir -p /root/.pyppeteer && chmod -R 777 /root/.pyppeteer
# Install system dependencies required for Chromium.
RUN apt-get update && apt-get install -y \
wget \
ca-certificates \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libgdk-pixbuf2.0-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
xdg-utils \
--no-install-recommends && rm -rf /var/lib/apt/lists/*
# Set the working directory.
WORKDIR /app
# Copy and install Python dependencies.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download the Chromium revision required by Pyppeteer.
RUN python -c "from pyppeteer import chromium_downloader; chromium_downloader.download_chromium()"
# Copy the rest of the application code.
COPY . .
# Expose port 7860.
EXPOSE 7860
# Start the FastAPI app using Uvicorn.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]