| # ============================================================================ | |
| # CPU-only Dockerfile for BackgroundFX Pro | |
| # For development, testing, or CPU-only deployments | |
| # ============================================================================ | |
| FROM python:3.10-slim | |
| # Set environment variables - INCLUDING MKL_NUM_THREADS to fix libgomp error | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| DEBIAN_FRONTEND=noninteractive \ | |
| DEVICE=cpu \ | |
| OMP_NUM_THREADS=4 \ | |
| MKL_NUM_THREADS=4 | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git wget curl \ | |
| ffmpeg \ | |
| libsm6 libxext6 libxrender1 libgl1-mesa-glx \ | |
| libglib2.0-0 libgomp1 \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Install Python dependencies | |
| COPY requirements-cpu.txt requirements.txt ./ | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir \ | |
| torch==2.1.0 --index-url https://download.pytorch.org/whl/cpu \ | |
| torchvision==0.16.0 --index-url https://download.pytorch.org/whl/cpu && \ | |
| pip install --no-cache-dir -r requirements.txt && \ | |
| pip install --no-deps \ | |
| git+https://github.com/pq-yang/MatAnyone.git@2234ce5cdc487749515518bd035b5e18bccea3da | |
| # Create app user | |
| RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app | |
| USER appuser | |
| # Copy application code | |
| COPY --chown=appuser:appuser . . | |
| # Create runtime directories | |
| RUN mkdir -p logs uploads outputs models/.cache | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| EXPOSE 7860 8000 | |
| # Launch | |
| CMD ["python", "-u", "app.py"] |