FROM python:3.11-slim # System deps needed by pypdf, python-docx, torch RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ libgomp1 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python dependencies (cached as a separate layer) COPY backend/requirements.txt ./requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy source COPY backend/ ./backend/ COPY frontend/ ./frontend/ # Runtime directories RUN mkdir -p uploads results .cache # HF Spaces requires port 7860 and runs containers as uid 1000 RUN useradd -m -u 1000 user && chown -R user:user /app USER user # PYTHONPATH=/app lets `from backend.X import ...` resolve correctly ENV PORT=7860 \ HOST=0.0.0.0 \ DEBUG=False \ PYTHONPATH=/app \ HF_HOME=/app/.cache/huggingface \ MODEL_CACHE_DIR=/app/.cache/models EXPOSE 7860 CMD ["python", "backend/main.py"]