myCrawl4ai-2 / Dockerfile
NightFury2710's picture
update api handle 3
f300b39
FROM python:3.10-slim
WORKDIR /code
# Install system dependencies and playwright dependencies as root
RUN apt-get update && apt-get install -y \
wget \
gnupg \
xvfb \
libgbm1 \
libnss3 \
libnspr4 \
libxss1 \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libdrm2 \
libgtk-3-0 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libpango-1.0-0 \
libcairo2 \
&& mkdir -p /etc/apt/sources.list.d \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google.gpg \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
# Create crawl4ai directory with proper permissions
RUN mkdir -p /.crawl4ai && chmod 777 /.crawl4ai
# Create non-root user early
RUN useradd -m myuser
USER myuser
# Copy requirements and install Python packages
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Install playwright and chromium browser only (no system dependencies)
RUN pip install --user playwright && \
python -m playwright install chromium
# Copy application code
COPY app.py .
# Run the application using python -m
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]