Arnel Gwen Nuqui commited on
Commit
6ac7b76
·
1 Parent(s): 4d83f29

Fix Dockerfile build for Hugging Face

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -14
Dockerfile CHANGED
@@ -1,32 +1,36 @@
1
- # Use lightweight Python image
 
 
 
 
2
  FROM python:3.10-slim
3
 
4
- # Prevent buffering and ensure logs show up instantly
5
  ENV PYTHONUNBUFFERED=1
 
6
 
7
- # Install necessary system dependencies
8
  RUN apt-get update && apt-get install -y \
9
  libgl1 \
10
  libglib2.0-0 \
11
- libopencv-dev \
12
  libatlas-base-dev \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # Set working directory
16
  WORKDIR /app
17
 
18
- # Copy requirements first (to leverage Docker cache)
19
- COPY requirements.txt /app/
20
 
21
- # Upgrade pip and install dependencies
22
- RUN pip install --no-cache-dir --upgrade pip
23
- RUN pip install --no-cache-dir -r requirements.txt
24
 
25
- # Copy the rest of your application
26
- COPY . /app
27
 
28
- # Expose the port used by Hugging Face Spaces
29
  EXPOSE 7860
30
 
31
- # Run Flask app
32
  CMD ["python", "app.py"]
 
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"]