VideoBackgroundReplacer2/Dockerfile
CHANGED
|
@@ -4,6 +4,8 @@
|
|
| 4 |
# SAM2 installed from source; MatAnyone via pip (repo)
|
| 5 |
# ===============================
|
| 6 |
|
|
|
|
|
|
|
| 7 |
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
|
| 8 |
|
| 9 |
# ---- Environment (runtime hygiene) ----
|
|
@@ -24,6 +26,11 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|
| 24 |
STREAMLIT_SERVER_HEADLESS=true \
|
| 25 |
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
# ---- Non-root user ----
|
| 28 |
RUN useradd -m -u 1000 user
|
| 29 |
ENV HOME=/home/user
|
|
@@ -32,14 +39,17 @@ WORKDIR $HOME/app
|
|
| 32 |
# ---- System deps ----
|
| 33 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 34 |
git ffmpeg wget curl \
|
| 35 |
-
|
| 36 |
build-essential gcc g++ pkg-config \
|
| 37 |
libffi-dev libssl-dev libc6-dev \
|
| 38 |
libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 \
|
|
|
|
|
|
|
|
|
|
| 39 |
&& rm -rf /var/lib/apt/lists/*
|
| 40 |
|
| 41 |
# ---- Python bootstrap ----
|
| 42 |
-
RUN python3 -m pip install --upgrade pip setuptools wheel
|
| 43 |
|
| 44 |
# ---- Install PyTorch (CUDA 12.1 wheels) ----
|
| 45 |
RUN python3 -m pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \
|
|
@@ -54,8 +64,9 @@ PY
|
|
| 54 |
# ---- Copy deps first (better caching) ----
|
| 55 |
COPY --chown=user:user requirements.txt ./
|
| 56 |
|
| 57 |
-
# ---- Install remaining Python deps ----
|
| 58 |
-
RUN
|
|
|
|
| 59 |
|
| 60 |
# ---- MatAnyone (pip install from repo with retry) ----
|
| 61 |
RUN echo "Installing MatAnyone..." && \
|
|
@@ -112,6 +123,10 @@ CMD ["sh", "-c", "\
|
|
| 112 |
echo 'Files in app directory:' && \
|
| 113 |
ls -la && \
|
| 114 |
echo '' && \
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
echo '=== APP.PY VERIFICATION ===' && \
|
| 116 |
if [ -f app.py ]; then \
|
| 117 |
echo '✅ app.py found' && \
|
|
|
|
| 4 |
# SAM2 installed from source; MatAnyone via pip (repo)
|
| 5 |
# ===============================
|
| 6 |
|
| 7 |
+
# Set Python version explicitly
|
| 8 |
+
ARG PYTHON_VERSION=3.10
|
| 9 |
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
|
| 10 |
|
| 11 |
# ---- Environment (runtime hygiene) ----
|
|
|
|
| 26 |
STREAMLIT_SERVER_HEADLESS=true \
|
| 27 |
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
| 28 |
|
| 29 |
+
# ---- System cleanup ----
|
| 30 |
+
RUN rm -rf /var/lib/apt/lists/* && \
|
| 31 |
+
apt-get clean && \
|
| 32 |
+
rm -rf /tmp/* /var/tmp/*
|
| 33 |
+
|
| 34 |
# ---- Non-root user ----
|
| 35 |
RUN useradd -m -u 1000 user
|
| 36 |
ENV HOME=/home/user
|
|
|
|
| 39 |
# ---- System deps ----
|
| 40 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 41 |
git ffmpeg wget curl \
|
| 42 |
+
python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python3-pip python${PYTHON_VERSION}-venv \
|
| 43 |
build-essential gcc g++ pkg-config \
|
| 44 |
libffi-dev libssl-dev libc6-dev \
|
| 45 |
libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 \
|
| 46 |
+
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
|
| 47 |
+
&& update-alternatives --set python3 /usr/bin/python${PYTHON_VERSION} \
|
| 48 |
+
&& ln -sf /usr/bin/python${PYTHON_VERSION} /usr/bin/python \
|
| 49 |
&& rm -rf /var/lib/apt/lists/*
|
| 50 |
|
| 51 |
# ---- Python bootstrap ----
|
| 52 |
+
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
|
| 53 |
|
| 54 |
# ---- Install PyTorch (CUDA 12.1 wheels) ----
|
| 55 |
RUN python3 -m pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \
|
|
|
|
| 64 |
# ---- Copy deps first (better caching) ----
|
| 65 |
COPY --chown=user:user requirements.txt ./
|
| 66 |
|
| 67 |
+
# ---- Install remaining Python deps with force reinstall ----
|
| 68 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 69 |
+
pip install --no-cache-dir -r requirements.txt --force-reinstall
|
| 70 |
|
| 71 |
# ---- MatAnyone (pip install from repo with retry) ----
|
| 72 |
RUN echo "Installing MatAnyone..." && \
|
|
|
|
| 123 |
echo 'Files in app directory:' && \
|
| 124 |
ls -la && \
|
| 125 |
echo '' && \
|
| 126 |
+
echo '=== PYTHON ENVIRONMENT ===' && \
|
| 127 |
+
python3 --version && \
|
| 128 |
+
pip --version && \
|
| 129 |
+
echo '' && \
|
| 130 |
echo '=== APP.PY VERIFICATION ===' && \
|
| 131 |
if [ -f app.py ]; then \
|
| 132 |
echo '✅ app.py found' && \
|