MogensR commited on
Commit
0b5fadf
·
1 Parent(s): ebbaebf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -46
Dockerfile CHANGED
@@ -1,35 +1,22 @@
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 \
14
- build-essential \
15
- cmake \
16
- pkg-config \
17
- libopencv-dev \
18
- python3-opencv \
19
- ffmpeg \
20
- libsm6 \
21
- libxext6 \
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
 
@@ -40,29 +27,28 @@ WORKDIR /app
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
@@ -71,11 +57,11 @@ ENV PATH="/home/appuser/.local/bin:$PATH"
71
  # Copy application code
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" \
80
  GRADIO_SERVER_PORT="7860" \
81
  MODEL_CACHE_DIR="/tmp/model_cache" \
@@ -85,8 +71,8 @@ ENV GRADIO_SERVER_NAME="0.0.0.0" \
85
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
86
  CMD curl -f http://localhost:7860/ || exit 1
87
 
88
- # Expose port
89
  EXPOSE 7860
90
 
91
- # Run the application
92
- CMD ["python", "app.py"]
 
1
+ # ============================================================================
2
+ # MatAnyOne + SAM2 + Gradio Dockerfile (Python 3.10 + CUDA 12.1)
3
+ # ============================================================================
4
 
5
+ # Use Python 3.10 base
6
+ FROM python:3.10-slim
7
+
8
+ # Environment settings
9
  ENV PYTHONDONTWRITEBYTECODE=1 \
10
  PYTHONUNBUFFERED=1 \
11
  DEBIAN_FRONTEND=noninteractive
12
 
13
  # Install system dependencies
14
+ RUN apt-get update && apt-get install -y --no-install-recommends \
15
+ git wget curl build-essential cmake pkg-config \
16
+ ffmpeg libsm6 libxext6 libfontconfig1 libxrender1 \
17
+ libgl1-mesa-glx libglib2.0-0 \
18
+ libavformat-dev libavcodec-dev libavdevice-dev \
19
+ libavutil-dev libswscale-dev libswresample-dev libavfilter-dev \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  && apt-get clean \
21
  && rm -rf /var/lib/apt/lists/*
22
 
 
27
  RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
28
  USER appuser
29
 
30
+ # Copy requirements for layer caching
31
  COPY --chown=appuser:appuser requirements.txt .
32
 
33
+ # Upgrade pip + core tools
34
  RUN pip install --no-cache-dir --user pip setuptools wheel
35
 
36
+ # Install PyTorch (CUDA 12.1 build)
37
  RUN pip install --no-cache-dir --user \
38
+ torch==2.1.0 \
39
+ torchvision==0.16.0 \
40
+ torchaudio==2.1.0 \
41
+ --extra-index-url https://download.pytorch.org/whl/cu121
42
 
43
+ # Install core CV/scientific dependencies
44
  RUN pip install --no-cache-dir --user \
45
+ numpy==1.26.4 \
46
+ opencv-python-headless==4.10.0.84 \
47
+ Pillow>=10.0.1,<11.0 \
48
+ scipy==1.13.1 \
49
+ av==12.1.0
 
50
 
51
+ # Install everything else from requirements.txt
52
  RUN pip install --no-cache-dir --user -r requirements.txt
53
 
54
  # Add user bin to PATH
 
57
  # Copy application code
58
  COPY --chown=appuser:appuser . .
59
 
60
+ # Create runtime directories
61
  RUN mkdir -p /tmp/model_cache /tmp/processing /tmp/jobs && \
62
  chmod 755 /tmp/model_cache /tmp/processing /tmp/jobs
63
 
64
+ # Runtime environment variables
65
  ENV GRADIO_SERVER_NAME="0.0.0.0" \
66
  GRADIO_SERVER_PORT="7860" \
67
  MODEL_CACHE_DIR="/tmp/model_cache" \
 
71
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
72
  CMD curl -f http://localhost:7860/ || exit 1
73
 
74
+ # Expose Gradio port
75
  EXPOSE 7860
76
 
77
+ # Run application
78
+ CMD ["python", "app.py"]