# HuggingFace Spaces (Docker SDK) — Flask + Gunicorn on port 7860 FROM python:3.10-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ PORT=7860 WORKDIR /app # System deps: libpq (psycopg2), libgl (torchvision/Pillow), git-lfs for *.pth/*.pkl RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential libpq-dev libgl1 libglib2.0-0 git git-lfs \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . # Install CPU-only torch first (much smaller than CUDA bundle), then the rest RUN pip install --upgrade pip && \ pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision && \ pip install -r requirements.txt COPY . . # Writable dirs for uploads + sqlite fallback RUN mkdir -p static/uploads instance && chmod -R 777 static/uploads instance EXPOSE 7860 # Tables auto-create on startup via database.init_database() CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "4", "--timeout", "120", "app:create_app()"]