Arnel Gwen Nuqui commited on
Commit
9b4e910
·
1 Parent(s): 6ac7b76

Fix Dockerfile for Hugging Face Space

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -15
Dockerfile CHANGED
@@ -1,36 +1,36 @@
1
  # ==============================================================
2
- # ✅ Hugging Face Dockerfile for Flask + TensorFlow + OpenCV
3
  # ==============================================================
4
 
5
- # 1. Use a stable lightweight base image
6
  FROM python:3.10-slim
7
 
8
- # 2. Avoid Python buffering and cache issues
9
  ENV PYTHONUNBUFFERED=1
10
- ENV PIP_NO_CACHE_DIR=1
11
 
12
- # 3. Install system dependencies
13
- RUN apt-get update && apt-get install -y \
14
  libgl1 \
15
  libglib2.0-0 \
16
  libatlas-base-dev \
17
- && rm -rf /var/lib/apt/lists/*
 
18
 
19
- # 4. Set working directory
20
  WORKDIR /app
21
 
22
- # 5. Copy requirements first for caching
23
  COPY requirements.txt .
24
 
25
- # 6. Upgrade pip + install dependencies safely
26
- RUN pip install --upgrade pip setuptools wheel
27
- RUN pip install -r requirements.txt
 
28
 
29
- # 7. Copy the rest of your app
30
  COPY . .
31
 
32
- # 8. Expose the Hugging Face port
33
  EXPOSE 7860
34
 
35
- # 9. Start Flask app
36
  CMD ["python", "app.py"]
 
1
  # ==============================================================
2
+ # ✅ Hugging Face Dockerfile for Flask + TensorFlow + MediaPipe
3
  # ==============================================================
4
 
 
5
  FROM python:3.10-slim
6
 
7
+ # Prevent log buffering
8
  ENV PYTHONUNBUFFERED=1
 
9
 
10
+ # Install system dependencies
11
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
12
  libgl1 \
13
  libglib2.0-0 \
14
  libatlas-base-dev \
15
+ ffmpeg \
16
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
17
 
18
+ # Set working directory
19
  WORKDIR /app
20
 
21
+ # Copy requirements first
22
  COPY requirements.txt .
23
 
24
+ # Install Python dependencies with retry logic
25
+ RUN pip install --upgrade pip
26
+ RUN pip install --no-cache-dir -r requirements.txt || \
27
+ (sleep 10 && pip install --no-cache-dir -r requirements.txt)
28
 
29
+ # Copy application files
30
  COPY . .
31
 
32
+ # Expose port 7860 for Hugging Face
33
  EXPOSE 7860
34
 
35
+ # Run Flask app
36
  CMD ["python", "app.py"]