Spaces:
Paused
Paused
Upload Dockerfile
Browse files12345 unmodified lines10111213141516171819202122232425262728293031# We use a slim Debian-based Linux imageFROM python:3.12-slim# Install system libraries required to run real Chromium + Xvfb5 unmodified lineschromium chromium-driver \&& rm -rf /var/lib/apt/lists/*# Set up the working directory inside the containerWORKDIR /app# Install our dependenciesCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# Copy our powerful API codeCOPY main.py .# Expose port 8000 for the host platformEXPOSE 8000# THE BYPASS TRICK:# We run Uvicorn wrapped in `xvfb-run` (X virtual framebuffer).# This "fakes" a physical computer monitor so that even inside a headless Linux server,# Chromium thinks it's running visibly on a real desk.# Cloudflare looks for screen dimensions; this fools them flawlessly!CMD ["xvfb-run", "-a", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]1235 unmodified lines910111213141516171819202122232425262728293031FROM python:3.12-slim# Install system libraries required to run real Chromium + Xvfb5 unmodified lineschromium chromium-driver \&& rm -rf /var/lib/apt/lists/*# Hugging Face enforces running as a non-root userRUN useradd -m -u 1000 userUSER userENV HOME=/home/user \PATH=/home/user/.local/bin:$PATHWORKDIR $HOME/app# Copy and install dependencies as the new userCOPY --chown=user requirements.txt .RUN pip install --no-cache-dir --user -r requirements.txt# Copy our powerful API codeCOPY --chown=user main.py .# Hugging Face rigidly requires port 7860EXPOSE 7860# We run Uvicorn wrapped in `xvfb-run` to fake a physical monitorCMD ["xvfb-run", "-a", "python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
Dockerfile+15-15