File size: 1,014 Bytes
86f1b1e
41de6ea
 
86f1b1e
41de6ea
 
86f1b1e
 
abdbea3
41de6ea
86f1b1e
 
abdbea3
86f1b1e
 
41de6ea
 
86f1b1e
41de6ea
 
 
 
86f1b1e
41de6ea
 
86f1b1e
 
 
 
 
 
 
 
 
 
 
41de6ea
 
86f1b1e
 
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
35
36
37
38
39
40
# Use Python 3.9 slim image
FROM python:3.9-slim

# Set working directory
WORKDIR /app

# Install system dependencies required for OpenCV
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    libgomp1 \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Copy all application files
COPY . .

# Create a non-root user for Hugging Face Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set working directory to user home
WORKDIR $HOME/app
COPY --chown=user . $HOME/app

# Expose port 7860 (required by Hugging Face Spaces)
EXPOSE 7860

# Run the application with gunicorn
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app", "--timeout", "120", "--workers", "1", "--threads", "2"]