Update Dockerfile
Browse files- Dockerfile +36 -18
Dockerfile
CHANGED
|
@@ -1,19 +1,13 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM
|
| 3 |
|
| 4 |
# Set environment variables
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PYTHONUNBUFFERED=1 \
|
| 7 |
-
DEBIAN_FRONTEND=noninteractive
|
| 8 |
-
TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6+PTX" \
|
| 9 |
-
FORCE_CUDA="1"
|
| 10 |
|
| 11 |
# Install system dependencies
|
| 12 |
RUN apt-get update && apt-get install -y \
|
| 13 |
-
python3.10 \
|
| 14 |
-
python3.10-dev \
|
| 15 |
-
python3-pip \
|
| 16 |
-
python3.10-venv \
|
| 17 |
git \
|
| 18 |
wget \
|
| 19 |
curl \
|
|
@@ -28,23 +22,47 @@ RUN apt-get update && apt-get install -y \
|
|
| 28 |
libfontconfig1 \
|
| 29 |
libxrender1 \
|
| 30 |
libgl1-mesa-glx \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
&& apt-get clean \
|
| 32 |
&& rm -rf /var/lib/apt/lists/*
|
| 33 |
|
| 34 |
-
# Create
|
| 35 |
WORKDIR /app
|
| 36 |
|
| 37 |
-
# Create non-root user
|
| 38 |
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
|
| 39 |
USER appuser
|
| 40 |
|
| 41 |
-
#
|
| 42 |
COPY --chown=appuser:appuser requirements.txt .
|
| 43 |
|
| 44 |
-
# Install
|
| 45 |
-
RUN pip install --no-cache-dir --user
|
| 46 |
|
| 47 |
-
# Install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 49 |
|
| 50 |
# Add user bin to PATH
|
|
@@ -54,8 +72,8 @@ ENV PATH="/home/appuser/.local/bin:$PATH"
|
|
| 54 |
COPY --chown=appuser:appuser . .
|
| 55 |
|
| 56 |
# Create necessary directories
|
| 57 |
-
RUN mkdir -p /tmp/model_cache /tmp/processing && \
|
| 58 |
-
chmod 755 /tmp/model_cache /tmp/processing
|
| 59 |
|
| 60 |
# Set environment variables for runtime
|
| 61 |
ENV GRADIO_SERVER_NAME="0.0.0.0" \
|
|
@@ -71,4 +89,4 @@ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
|
| 71 |
EXPOSE 7860
|
| 72 |
|
| 73 |
# Run the application
|
| 74 |
-
CMD ["
|
|
|
|
| 1 |
+
# Use Python 3.9 base image for MatAnyone compatibility
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set environment variables
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PYTHONUNBUFFERED=1 \
|
| 7 |
+
DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Install system dependencies
|
| 10 |
RUN apt-get update && apt-get install -y \
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
git \
|
| 12 |
wget \
|
| 13 |
curl \
|
|
|
|
| 22 |
libfontconfig1 \
|
| 23 |
libxrender1 \
|
| 24 |
libgl1-mesa-glx \
|
| 25 |
+
libglib2.0-0 \
|
| 26 |
+
libavformat-dev \
|
| 27 |
+
libavcodec-dev \
|
| 28 |
+
libavdevice-dev \
|
| 29 |
+
libavutil-dev \
|
| 30 |
+
libswscale-dev \
|
| 31 |
+
libswresample-dev \
|
| 32 |
+
libavfilter-dev \
|
| 33 |
&& apt-get clean \
|
| 34 |
&& rm -rf /var/lib/apt/lists/*
|
| 35 |
|
| 36 |
+
# Create working directory
|
| 37 |
WORKDIR /app
|
| 38 |
|
| 39 |
+
# Create non-root user
|
| 40 |
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
|
| 41 |
USER appuser
|
| 42 |
|
| 43 |
+
# Copy requirements first for better caching
|
| 44 |
COPY --chown=appuser:appuser requirements.txt .
|
| 45 |
|
| 46 |
+
# Install Python dependencies in stages for better error handling
|
| 47 |
+
RUN pip install --no-cache-dir --user pip setuptools wheel
|
| 48 |
|
| 49 |
+
# Install PyTorch first (most stable approach)
|
| 50 |
+
RUN pip install --no-cache-dir --user \
|
| 51 |
+
torch==2.0.1 \
|
| 52 |
+
torchvision==0.15.2 \
|
| 53 |
+
torchaudio==2.0.1 \
|
| 54 |
+
--index-url https://download.pytorch.org/whl/cpu
|
| 55 |
+
|
| 56 |
+
# Install core dependencies
|
| 57 |
+
RUN pip install --no-cache-dir --user \
|
| 58 |
+
numpy==1.24.3 \
|
| 59 |
+
opencv-python-headless==4.8.0.76 \
|
| 60 |
+
Pillow==10.0.1
|
| 61 |
+
|
| 62 |
+
# Install AV package with build dependencies
|
| 63 |
+
RUN pip install --no-cache-dir --user av==10.0.0
|
| 64 |
+
|
| 65 |
+
# Install remaining requirements
|
| 66 |
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 67 |
|
| 68 |
# Add user bin to PATH
|
|
|
|
| 72 |
COPY --chown=appuser:appuser . .
|
| 73 |
|
| 74 |
# Create necessary directories
|
| 75 |
+
RUN mkdir -p /tmp/model_cache /tmp/processing /tmp/jobs && \
|
| 76 |
+
chmod 755 /tmp/model_cache /tmp/processing /tmp/jobs
|
| 77 |
|
| 78 |
# Set environment variables for runtime
|
| 79 |
ENV GRADIO_SERVER_NAME="0.0.0.0" \
|
|
|
|
| 89 |
EXPOSE 7860
|
| 90 |
|
| 91 |
# Run the application
|
| 92 |
+
CMD ["python", "app.py"]
|