File size: 1,117 Bytes
24ed131
 
5592609
 
abb3a15
 
5592609
 
 
 
abb3a15
 
5592609
 
97b1b9b
24ed131
 
97b1b9b
24ed131
 
5592609
24ed131
 
97b1b9b
24ed131
 
97b1b9b
1b378f9
 
97b1b9b
 
5592609
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM python:3.12-slim

# Install system dependencies required by OpenCV (cv2)
# libgl1 is required for libGL.so.1
# libsm6 and libxext6 are commonly needed by imaging libraries in a headless environment.
# libglib2.0-0 is required for libgthread-2.0.so.0
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    libgl1 \
    libsm6 \
    libxext6 \
    libglib2.0-0 && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt .

# Install all Python dependencies, including opencv-python, which now finds its system libraries.
RUN pip install --no-cache-dir -r requirements.txt

# Install gunicorn to run the Flask app
RUN pip install gunicorn

# Copy all application code into the current directory (/app)
COPY . .

# Define the default command to run the application using gunicorn.
# The 'app:app' assumes your Flask app instance is named 'app' inside 'app.py'.
# The port is set to 7860 as required by Hugging Face Spaces.
CMD exec gunicorn --bind :7860 --workers 1 --threads 8 app:app