Fix connection reset: Improve video streaming, increase timeouts, and add better error handling
33da647
| FROM python:3.10-slim | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 | |
| # System deps for OpenCV/ffmpeg and build tools for insightface | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| ffmpeg \ | |
| libgl1 \ | |
| build-essential \ | |
| g++ \ | |
| make \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Install Python deps | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy source | |
| COPY . . | |
| EXPOSE 7860 | |
| # Optional: set at runtime | |
| ENV FACE_SWAP_API_KEY="" | |
| ENV OMP_NUM_THREADS=1 | |
| CMD ["python3", "-m", "uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "1800", "--timeout-graceful-shutdown", "30"] | |