Spaces:
Build error
Build error
| # 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"] | |