File size: 868 Bytes
5494ea8
 
 
 
 
 
ae53254
 
 
 
5494ea8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109dea0
 
 
 
 
5494ea8
 
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
# Use a minimal Python image
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Set environment variables for writable config directories
ENV MPLCONFIGDIR=/tmp/matplotlib
ENV YOLO_CONFIG_DIR=/tmp/Ultralytics

# Install required system libraries
RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0

# Install PyTorch separately to avoid timeout
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

# Copy dependencies
COPY requirements.txt ./

# Install remaining dependencies
RUN pip install --no-cache-dir -r requirements.txt --timeout 100 --index-url https://pypi.tuna.tsinghua.edu.cn/simple

# Copy application code
COPY . .

# Expose port 7860 for Hugging Face Spaces
EXPOSE 7860

# Run FastAPI on port 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]