# ╔══════════════════════════════════════════════════════════════╗ # ║ Dockerfile — Cloudflare AI API ║ # ║ Stack: Python 3.11 · FastAPI · Chrome · Xvfb ║ # ║ Port: 7860 ║ # ╚══════════════════════════════════════════════════════════════╝ FROM python:3.11-slim ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 SHELL ["/bin/bash", "-o", "pipefail", "-c"] # System deps RUN apt-get update && apt-get install -y --no-install-recommends \ xvfb \ x11-utils \ wget \ ca-certificates \ gnupg \ curl \ libx11-6 \ libx11-xcb1 \ libxcb1 \ libxcomposite1 \ libxcursor1 \ libxdamage1 \ libxext6 \ libxfixes3 \ libxi6 \ libxrandr2 \ libxrender1 \ libxss1 \ libxtst6 \ libglib2.0-0 \ libgtk-3-0 \ libnspr4 \ libnss3 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libdrm2 \ libgbm1 \ libcups2 \ libasound2 \ libpango-1.0-0 \ libpangocairo-1.0-0 \ fonts-liberation \ xdg-utils \ lsb-release \ procps \ && rm -rf /var/lib/apt/lists/* # Google Chrome stable RUN wget -q -O /tmp/chrome.deb \ https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ && apt-get update \ && apt-get install -y --no-install-recommends /tmp/chrome.deb \ && rm -f /tmp/chrome.deb \ && rm -rf /var/lib/apt/lists/* \ && google-chrome --version # Pre-create X11 socket directory RUN mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix WORKDIR /app # Python deps COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # App source COPY cloudflare_provider.py server.py entrypoint.sh ./ # User + permissions RUN useradd -m -u 1000 appuser \ && mkdir -p /app/cache \ && chown -R appuser:appuser /app \ && chmod +x /app/entrypoint.sh \ && chmod 1777 /tmp/.X11-unix USER appuser ENV DISPLAY=:99 \ XVFB_EXTERNAL=1 \ POOL_SIZE=2 \ PORT=7860 \ HOST=0.0.0.0 \ HEALTH_INTERVAL=60 \ DEFAULT_MODEL=@cf/moonshotai/kimi-k2.5 EXPOSE 7860 CMD ["/app/entrypoint.sh"]