Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| ENV PYTHONUNBUFFERED=1 \ | |
| GRADIO_SERVER_NAME="0.0.0.0" \ | |
| GRADIO_SERVER_PORT=7860 \ | |
| HOME=/home/user \ | |
| PLAYWRIGHT_BROWSERS_PATH=/usr/lib/playwright | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg libsm6 libxext6 git curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN useradd -m -u 1000 user | |
| ENV PATH="/home/user/.local/bin:${PATH}" | |
| WORKDIR $HOME/app | |
| # Clone FaceFusion | |
| ARG COMMIT_HASH=a7f3de3dbc503bd3d6d3ca13d0b303db450e270a | |
| RUN git clone https://github.com/facefusion/facefusion.git . && \ | |
| git reset --hard ${COMMIT_HASH} | |
| # Install requirements + Web Server needs | |
| RUN pip install --no-cache-dir -r requirements.txt && \ | |
| pip install --no-cache-dir fastapi uvicorn python-multipart requests httpx beautifulsoup4 playwright playwright-stealth | |
| RUN playwright install chromium | |
| RUN playwright install-deps chromium | |
| # This changes ownership of everything you just cloned/installed | |
| RUN chown -R user:user $HOME | |
| USER user | |
| # Copy your source face image into the container | |
| COPY --chown=user:user source.jpg . | |
| # Copy your custom app script | |
| COPY --chown=user:user *.py . | |
| # Apply your existing patches | |
| COPY --chown=user:user patches/core.py facefusion/core.py | |
| COPY --chown=user:user patches/content_analyser.py facefusion/content_analyser.py | |
| COPY --chown=user:user patches/facefusion.ini facefusion.ini | |
| EXPOSE 7860 | |
| # Run the FastAPI app on port 7860 | |
| CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |