| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies for OpenCV and MediaPipe | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender1 \ | |
| libgomp1 \ | |
| libgstreamer1.0-0 \ | |
| libgstreamer-plugins-base1.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first (for better caching) | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Create necessary directories with proper permissions | |
| RUN mkdir -p temp models logs && \ | |
| chmod -R 777 temp logs | |
| # Expose port | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | |
| CMD python -c "import requests; requests.get('http://localhost:7860/health')" | |
| # Run both API server and worker using Python startup script | |
| CMD ["python", "start.py"] | |