Arnel Gwen Nuqui commited on
Commit
4d83f29
·
1 Parent(s): 44ed412

Fix Dockerfile for Hugging Face deployment

Browse files
Files changed (2) hide show
  1. Dockerfile +13 -19
  2. requirements.txt +1 -1
Dockerfile CHANGED
@@ -1,38 +1,32 @@
1
- # ------------------------------------------------------------
2
- # Hugging Face Spaces - Docker Flask + TensorFlow + MediaPipe
3
- # ------------------------------------------------------------
4
-
5
- # Base image (Python + system deps)
6
  FROM python:3.10-slim
7
 
8
- # Disable interactive prompts
9
- ENV DEBIAN_FRONTEND=noninteractive
10
  ENV PYTHONUNBUFFERED=1
11
- ENV PYTHONDONTWRITEBYTECODE=1
12
 
13
- # Install system packages
14
  RUN apt-get update && apt-get install -y \
15
  libgl1 \
16
  libglib2.0-0 \
17
- libopencv-core-dev \
18
  libatlas-base-dev \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
- # Set work directory
22
  WORKDIR /app
23
 
24
- # Copy dependency list
25
- COPY requirements.txt .
26
 
27
  # Upgrade pip and install dependencies
28
- RUN pip install --no-cache-dir --upgrade pip \
29
- && pip install --no-cache-dir -r requirements.txt
30
 
31
- # Copy the full project
32
- COPY . .
33
 
34
- # Expose Space default port
35
  EXPOSE 7860
36
 
37
- # Command to run the Flask server
38
  CMD ["python", "app.py"]
 
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"]
requirements.txt CHANGED
@@ -4,5 +4,5 @@ numpy==1.26.4
4
  opencv-python-headless==4.9.0.80
5
  mediapipe==0.10.14
6
  Pillow==10.3.0
7
- gunicorn==21.2.0
8
  tensorflow-cpu==2.15.0
 
 
4
  opencv-python-headless==4.9.0.80
5
  mediapipe==0.10.14
6
  Pillow==10.3.0
 
7
  tensorflow-cpu==2.15.0
8
+ gunicorn==21.2.0