WebashalarForML commited on
Commit
cd1c1fb
·
verified ·
1 Parent(s): 671d696

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -20
Dockerfile CHANGED
@@ -1,41 +1,39 @@
1
  FROM python:3.11-slim
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
 
4
  ENV PORT=7860
5
 
6
  WORKDIR /app
7
 
8
- # --- System dependencies (OpenCV, ffmpeg, etc.) ---
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
  build-essential \
 
11
  git \
12
- ca-certificates \
13
  ffmpeg \
14
- libgl1 \
15
- libglib2.0-0 \
16
- libsm6 \
17
- libxrender1 \
18
- libxext6 \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
- # --- Copy project ---
22
- COPY . /app
23
 
24
- # --- Create required folders (uploads, results, Model) ---
25
- RUN mkdir -p /app/static/uploads /app/static/results
26
 
27
- # --- Give write permissions (HF Spaces safe) ---
28
- RUN chmod -R 777 /app/static/uploads /app/static/results
 
29
 
30
- # --- Python tooling ---
31
- RUN python -m pip install --upgrade pip setuptools wheel huggingface_hub
32
 
33
- # --- Install dependencies ---
34
- COPY requirements.txt /app/requirements.txt
35
- RUN pip install --no-cache-dir -r requirements.txt
36
 
37
- # --- HF Spaces port ---
38
  EXPOSE 7860
39
 
40
- # --- Run Flask-SocketIO app ---
41
  CMD ["python", "-u", "app.py"]
 
1
  FROM python:3.11-slim
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
+ ENV PYTHONUNBUFFERED=1
5
  ENV PORT=7860
6
 
7
  WORKDIR /app
8
 
9
+ # --- System dependencies (Optimized for WebRTC & CV) ---
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
  build-essential \
12
+ pkg-config \
13
  git \
 
14
  ffmpeg \
15
+ libavdevice-dev libavfilter-dev libavformat-dev libavcodec-dev \
16
+ libswresample-dev libswscale-dev libavutil-dev \
17
+ libgl1 libglib2.0-0 \
18
+ # Speed trick: TCMalloc for better memory management in PyTorch
19
+ libgoogle-perftools-dev \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
+ # Set TCMalloc as the memory allocator
23
+ ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4"
24
 
25
+ # --- Python Setup ---
26
+ RUN python -m pip install --upgrade pip setuptools wheel
27
 
28
+ # --- Dependencies ---
29
+ COPY requirements.txt .
30
+ RUN pip install --no-cache-dir -r requirements.txt
31
 
32
+ COPY . .
 
33
 
34
+ # Setup permissions
35
+ RUN mkdir -p static/uploads static/results && chmod -R 777 static/uploads static/results
 
36
 
 
37
  EXPOSE 7860
38
 
 
39
  CMD ["python", "-u", "app.py"]