ARG BASE=python:3.11-slim
FROM ${BASE}
ARG TORCH_INDEX=https://download.pytorch.org/whl/cpu
ENV DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y --no-install-recommends git curl libgl1 libglib2.0-0 python3 python3-pip \
    && rm -rf /var/lib/apt/lists/*
RUN git clone --depth 1 https://github.com/Rudrabha/Wav2Lip.git /opt/Wav2Lip
WORKDIR /app
COPY requirements.txt .
RUN python3 -m pip install --no-cache-dir torch --index-url ${TORCH_INDEX} \
    && python3 -m pip install --no-cache-dir -r requirements.txt
# Pre-trained Wav2Lip GAN weights (research/non-commercial licence of Wav2Lip applies).
ARG WAV2LIP_URL=https://huggingface.co/Nekochu/Wav2Lip/resolve/main/wav2lip_gan.pth
RUN mkdir -p /models && curl -L --fail -o /models/wav2lip_gan.pth "${WAV2LIP_URL}"
COPY server.py .
EXPOSE 8765
CMD ["python3", "-m", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8765", "--ws-max-size", "4194304"]
