Spaces:
Running
Running
| # ============================================================ | |
| # VoiceVault β Docker Image for Hugging Face Spaces | |
| # ============================================================ | |
| # Base: Python 3.11-slim (stable, widely supported on HF) | |
| # Runtime: CPU-only (Groq cloud API for transcription + LLM) | |
| # Port: 7860 (HF Spaces default) | |
| # ============================================================ | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # ββ System dependencies ββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # build-essential : compiles C extensions (chromadb, numpy, etc.) | |
| # git : some pip packages clone during install | |
| # tesseract-ocr : OCR fallback for scanned PDFs (pytesseract) | |
| # libsndfile1 : soundfile audio I/O library (WAV reading for VAD) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| git \ | |
| tesseract-ocr \ | |
| libsndfile1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ββ Python: CPU-only PyTorch FIRST ββββββββββββββββββββββββββββββββββββ | |
| # Install before requirements.txt so pip reuses this install (~650MB) | |
| # instead of the CUDA wheel from PyPI (~2.5GB). | |
| RUN pip install --no-cache-dir \ | |
| torch==2.5.1 \ | |
| --index-url https://download.pytorch.org/whl/cpu | |
| # ββ Python: all other dependencies ββββββββββββββββββββββββββββββββββββ | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # ββ spaCy language model βββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Required by SemanticChunker for sentence tokenization during ingestion. | |
| RUN python -m spacy download en_core_web_sm | |
| # ββ Pre-download ML models ββββββββββββββββββββββββββββββββββββββββββββ | |
| # Baking models into the image avoids slow cold-start downloads in prod. | |
| # Embedding model (~90 MB) β used for vector search | |
| # Cross-encoder (~67 MB) β used for reranking retrieved chunks | |
| ENV HF_HOME=/app/cache | |
| ENV TRANSFORMERS_CACHE=/app/cache | |
| ENV SENTENCE_TRANSFORMERS_HOME=/app/cache | |
| RUN python -c "\ | |
| from sentence_transformers import SentenceTransformer, CrossEncoder; \ | |
| SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2'); \ | |
| CrossEncoder('cross-encoder/ms-marco-MiniLM-L12-v2'); \ | |
| print('Models pre-downloaded successfully.')" | |
| # ββ Application code ββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY . . | |
| # ββ Runtime directories βββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN mkdir -p data/uploads models | |
| # ββ Environment βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Force CPU β avoids CUDA errors on HF CPU-only hardware | |
| ENV CUDA_VISIBLE_DEVICES=-1 | |
| # Suppress Windows-only symlink warning (harmless, reduces log noise) | |
| ENV HF_HUB_DISABLE_SYMLINKS_WARNING=1 | |
| # Ensure Python output is unbuffered (logs appear immediately) | |
| ENV PYTHONUNBUFFERED=1 | |
| # Server binding β HF Spaces requires 0.0.0.0:7860 | |
| ENV HOST=0.0.0.0 | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # ββ Entrypoint ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| CMD ["python", "server.py"] | |