# Base Image (Stable Bullseye) FROM python:3.9-slim-bullseye # 1. Install System Dependencies RUN apt-get update && apt-get install -y \ libcairo2 \ libpango-1.0-0 \ libpangocairo-1.0-0 \ libgdk-pixbuf2.0-0 \ libffi-dev \ shared-mime-info \ && rm -rf /var/lib/apt/lists/* # 2. Setup User for Hugging Face Security RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # 3. Working Directory WORKDIR /app # 4. Copy & Install Requirements COPY --chown=user requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # 5. Copy App Code COPY --chown=user app.py app.py # 6. Expose Port 7860 EXPOSE 7860 # 7. Start Command (UPDATED FOR STABILITY) # --timeout 300: 5 minute tak kill nahi karega # --workers 1: Sirf 1 worker chalega taake RAM out of memory na ho # --threads 8: Speed ke liye threads use honge CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "300", "--workers", "1", "--threads", "8", "app:app"]