MusetalkLive / Dockerfile
segestic's picture
Update Dockerfile
86a4a6f verified
# syntax=docker/dockerfile:1
##############################################################################
# MuseTalk-ready Dockerfile (cleaned, consistent, safer installs)
##############################################################################
FROM python:3.9-slim
# Build-time args
ARG REPO="https://github.com/TMElyralab/MuseTalk.git"
ARG BRANCH="main"
ARG INSTALL_POSE="false"
ENV DEBIAN_FRONTEND=noninteractive
ENV MODEL_DIR=/app/models
WORKDIR /app
LABEL org.opencontainers.image.source=${REPO}
# Install system dependencies in a single layer
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
git \
ffmpeg \
build-essential \
python3-dev \
libgl1-mesa-glx \
libglib2.0-0 \
libjpeg-dev \
libpng-dev && \
rm -rf /var/lib/apt/lists/*
# Shallow clone the repository
RUN set -eux; \
git clone --depth 1 --branch "${BRANCH}" "${REPO}" . && \
git submodule update --init --recursive
# Overlay local build context (if any)
COPY . .
# Upgrade pip and install requirements
RUN set -eux; \
pip install --no-cache-dir --upgrade pip setuptools wheel
# Install requirements.txt if present, fail if missing (adjust if optional)
RUN set -eux; \
if [ -f requirements.txt ]; then \
pip install --no-cache-dir -r requirements.txt; \
else \
echo "Warning: requirements.txt not found; ensure dependencies are installed manually"; \
fi
# Install additional Python packages with pinned versions
RUN set -eux; \
pip install --no-cache-dir \
livekit==1.0.7 \
livekit-api==1.0.2 \
omegaconf \
transformers==4.39.3 \
protobuf==3.20.3 --force-reinstall
# Install optional pose/mm packages if enabled
RUN set -eux; \
if [ "${INSTALL_POSE}" = "true" ]; then \
pip install --no-cache-dir cython; \
pip install --no-cache-dir git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI; \
pip install --no-cache-dir openmim; \
pip install --no-cache-dir mmengine==0.10.7 mmcv==2.0.0rc4; \
python -m mim install mmpose; \
python -m mim install mmdet; \
else \
echo "Skipping pose/mm installation (set --build-arg INSTALL_POSE=true to enable)"; \
fi
# Ensure model directory exists
RUN mkdir -p "${MODEL_DIR}"
# Expose ports (confirm these match app.py requirements)
EXPOSE 7860 8000
# Verify app.py exists before running
CMD ["sh", "-c", "if [ -f app.py ]; then python3 app.py; else echo 'Error: app.py not found'; exit 1; fi"]