Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| # Install uv | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| # Set the working directory to /app | |
| WORKDIR /app | |
| # Install system dependencies required for MediaPipe, OpenCV, and video processing | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| ffmpeg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the final requirements file into the container | |
| COPY req_final.txt . | |
| # Install dependencies using uv (Python 3.11 to match req_final.txt pins) | |
| # Remove msvc-runtime since it is Windows-only | |
| RUN sed -i '/msvc-runtime/d' req_final.txt && \ | |
| uv pip install --system --no-cache -r req_final.txt gunicorn | |
| # Copy all the backend files into the container | |
| COPY . . | |
| # Hugging Face Spaces required setup for permissions | |
| RUN useradd -m -u 1000 user && \ | |
| mkdir -p /app/static/outputs /app/static/uploads && \ | |
| chown -R user:user /app | |
| USER user | |
| # HF Spaces bind to port 7860 by default for Docker spaces | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Run the Flask app using Gunicorn | |
| CMD ["gunicorn", "app:app", "-b", "0.0.0.0:7860", "--timeout", "300"] | |