segestic commited on
Commit
8a96b9c
·
verified ·
1 Parent(s): e3b8dd3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +82 -42
Dockerfile CHANGED
@@ -1,52 +1,92 @@
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.9-slim
2
 
3
- # Set working directory early
 
 
 
 
 
 
4
  WORKDIR /app
5
 
6
- # Install system dependencies with cleanup
7
- RUN apt-get update && apt-get install -y --no-install-recommends \
8
- ffmpeg \
9
- git \
10
- libgl1-mesa-glx \
11
- libglib2.0-0 \
12
- build-essential \
13
- python3-dev \
14
- libjpeg-dev \
15
- libpng-dev \
 
 
 
 
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
- # Copy only what’s needed early for caching
19
- COPY requirements.txt .
20
- COPY scripts ./scripts
21
- COPY configs ./configs
22
 
23
- # Upgrade pip + install Python deps
24
- RUN pip install --upgrade pip && \
25
- pip install --no-cache-dir -r requirements.txt
26
- # Install LiveKit SDKs
27
- RUN pip install --no-cache-dir \
28
- livekit==1.0.7 \
29
- livekit-api==1.0.2 \
30
- omegaconf \
31
- transformers==4.39.3 \
32
- && pip uninstall -y protobuf && pip install --no-cache-dir protobuf==3.20.3
33
-
34
- # Install pose dependencies (with caching minimized)
35
- RUN pip install --no-cache-dir cython && \
36
- pip install --no-cache-dir git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI
37
-
38
- RUN pip install --no-cache-dir mmengine==0.10.7 mmcv==2.0.0rc4 && \
39
- pip install --no-cache-dir openmim && \
40
- mim install mmpose && \
41
- mim install mmdet
42
-
43
- # Copy rest of the code
44
  COPY . .
45
 
46
- # Final cleanup (in case anything big remains)
47
- RUN apt-get clean && \
48
- find /root/.cache -type f -delete && \
49
- rm -rf /root/.cache/pip
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- # Set entrypoint
52
- # CMD ["python3", "-m", "scripts.realtime_inference", "--version", "v15", "--inference_config", "configs/inference/realtime.yaml"]
 
 
1
+ # syntax=docker/dockerfile:1
2
+ ##############################################################################
3
+ # MuseTalk-ready Dockerfile
4
+ # - clones upstream repo (default)
5
+ # - overlays local build context if present (so local app.py / configs / requirements.txt override cloned ones)
6
+ # - installs requirements (from local if provided, otherwise from cloned repo)
7
+ # - optionally installs heavy pose/mm deps via build-arg INSTALL_POSE=true
8
+ # - does NOT download large model weights during build (mount at runtime)
9
+ ##############################################################################
10
+
11
  FROM python:3.9-slim
12
 
13
+ # Repo to clone and branch (override at build time if needed)
14
+ ARG REPO="https://github.com/TMElyralab/MuseTalk.git"
15
+ ARG BRANCH="main"
16
+ ARG INSTALL_POSE="false" # set to "true" to install mmpose/mm packages (image grows)
17
+ ARG PYTHONUNBUFFERED="1"
18
+ ENV DEBIAN_FRONTEND=noninteractive
19
+ ENV MODEL_DIR=/app/models
20
  WORKDIR /app
21
 
22
+ LABEL org.opencontainers.image.source=${REPO}
23
+
24
+ # ----------------- system deps -----------------
25
+ RUN apt-get update \
26
+ && apt-get install -y --no-install-recommends \
27
+ ca-certificates \
28
+ git \
29
+ ffmpeg \
30
+ build-essential \
31
+ python3-dev \
32
+ libgl1-mesa-glx \
33
+ libglib2.0-0 \
34
+ libjpeg-dev \
35
+ libpng-dev \
36
  && rm -rf /var/lib/apt/lists/*
37
 
38
+ # ----------------- clone upstream repo into image -----------------
39
+ # Shallow clone to keep image smaller (override REPO/BRANCH via --build-arg)
40
+ RUN git clone --depth 1 --branch ${BRANCH} ${REPO} . \
41
+ && git submodule update --init --recursive || true
42
 
43
+ # ----------------- overlay local build context (if any) -----------------
44
+ # If you run `docker build` from the repo root, your local files (app.py, configs/, requirements.txt, etc.)
45
+ # will overwrite the cloned files. If you build from an empty folder, this COPY is effectively a no-op.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  COPY . .
47
 
48
+ # ----------------- python tooling & install requirements -----------------
49
+ RUN pip install --upgrade pip setuptools wheel
50
+
51
+ # Install requirements if the file exists (it will come from local build context if present, otherwise from cloned repo)
52
+ RUN if [ -f requirements.txt ]; then \
53
+ pip install --no-cache-dir -r requirements.txt ; \
54
+ else \
55
+ echo "No requirements.txt found; skipping pip install -r requirements.txt"; \
56
+ fi
57
+
58
+ # Install common extra packages used by the project and pin protobuf to avoid compatibility issues
59
+ RUN pip install --no-cache-dir \
60
+ livekit==1.0.7 \
61
+ livekit-api==1.0.2 \
62
+ omegaconf \
63
+ transformers==4.39.3 \
64
+ || true \
65
+ && pip uninstall -y protobuf || true \
66
+ && pip install --no-cache-dir protobuf==3.20.3 || true
67
+
68
+ # ----------------- optional heavy pose/mm packages -----------------
69
+ RUN if [ "${INSTALL_POSE}" = "true" ]; then \
70
+ pip install --no-cache-dir cython || true; \
71
+ pip install --no-cache-dir git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI || true; \
72
+ pip install --no-cache-dir openmim || true; \
73
+ pip install --no-cache-dir mmengine==0.10.7 mmcv==2.0.0rc4 || true; \
74
+ mim install mmpose || true; \
75
+ mim install mmdet || true; \
76
+ else \
77
+ echo "Skipping pose/mm installation (set --build-arg INSTALL_POSE=true to enable)"; \
78
+ fi
79
+
80
+ # ----------------- housekeeping -----------------
81
+ RUN find /root/.cache -type f -delete || true \
82
+ && rm -rf /root/.cache/pip || true
83
+
84
+ # Make sure model dir exists (mount your weights here at runtime)
85
+ RUN mkdir -p ${MODEL_DIR}
86
+
87
+ # Expose typical ports (adjust if your app uses different ports)
88
+ EXPOSE 7860 8000
89
 
90
+ # ----------------- runtime command -----------------
91
+ # Expect that /app/app.py exists in the repo (cloned or from local). If it's in a subfolder, update CMD.
92
+ CMD ["python3", "app.py"]