Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| # OpenCV dependencies (updated package names for newer Debian) | |
| libgl1-mesa-dev \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| libgomp1 \ | |
| libgthread-2.0-0 \ | |
| # Additional OpenGL/graphics libraries | |
| libglvnd0 \ | |
| libgl1 \ | |
| libglx0 \ | |
| libegl1 \ | |
| # GTK dependencies | |
| libgtk-3-0 \ | |
| # FFmpeg for video processing | |
| ffmpeg \ | |
| # Build tools for compiling Python packages | |
| build-essential \ | |
| # Download tools | |
| wget \ | |
| curl \ | |
| git \ | |
| # Additional dependencies for some Python packages | |
| pkg-config \ | |
| # Clean up | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && apt-get clean | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| # Upgrade pip and install wheel | |
| RUN pip install --upgrade pip setuptools wheel | |
| # Install PyTorch first (helps with dependency resolution) | |
| RUN pip install --no-cache-dir torch>=2.0.0 torchvision>=0.15.0 | |
| # Install other dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application files | |
| COPY . . | |
| # Create necessary directories | |
| RUN mkdir -p /data/uploads /data/outputs /data/models | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV FLASK_APP=app.py | |
| ENV FLASK_ENV=production | |
| ENV TORCH_HOME=/data/models | |
| # Expose port | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | |
| CMD curl -f http://localhost:7860/ || exit 1 | |
| # Run the application | |
| CMD ["python", "app.py"] |