File size: 749 Bytes
e2d9248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.9-slim

WORKDIR /app

# Install system dependencies if needed (e.g. for OpenCV if strictly required, but we use PIL)
# RUN apt-get update && apt-get install -y libgl1-mesa-glx && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

# Install dependencies
# Using the CPU-only index for PyTorch to keep image size smaller
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# Create a non-root user (optional but good practice, HF Spaces runs as user 1000 usually)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

WORKDIR /app

# Expose the port used by HF Spaces
EXPOSE 7860

# Command to run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]