Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender1 \ | |
| libgomp1 \ | |
| libgthread-2.0-0 \ | |
| curl \ | |
| wget \ | |
| ffmpeg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Download YOLOv8 model during build | |
| RUN python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')" | |
| # Copy application files | |
| COPY app.py . | |
| COPY templates/ ./templates/ | |
| # Create necessary directories with proper permissions | |
| RUN mkdir -p uploads outputs && chmod 777 uploads outputs | |
| # Expose port | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV MPLCONFIGDIR=/tmp/matplotlib | |
| ENV YOLO_CONFIG_DIR=/tmp | |
| # Run the application | |
| CMD ["python", "app.py"] | |