Spaces:
Sleeping
Sleeping
| # ββ Stage 1: Build image ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM python:3.10-slim | |
| # System deps needed by some python packages (pdfplumber, lxml, etc.) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libglib2.0-0 \ | |
| libgomp1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # ββ Install Python deps βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Download the sentence-transformer model at build time so it's baked in | |
| # (avoids downloading at runtime on every cold start) | |
| RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" | |
| # ββ Copy application code βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY app/ app/ | |
| COPY pipelines/ pipelines/ | |
| COPY config.py config.py | |
| COPY db.py db.py | |
| COPY run.py run.py | |
| # ββ Copy pre-built databases (generated locally before deployment) βββββββββββββ | |
| # These are read-only at runtime β no pipeline runs on the server. | |
| COPY promisetrack.db promisetrack.db | |
| COPY chroma_db/ chroma_db/ | |
| # ββ Copy the trained DistilBERT model checkpoint ββββββββββββββββββββββββββββββ | |
| COPY claim_classification_model_distilbert_trained/ \ | |
| claim_classification_model_distilbert_trained/ | |
| # ββ Logo cache (optional β pre-warm if desired, otherwise fetched on demand) ββ | |
| COPY data/logos/ data/logos/ | |
| # ββ Expose port 7860 (HuggingFace Spaces standard) βββββββββββββββββββββββββββ | |
| EXPOSE 7860 | |
| # ββ Set env defaults (real secrets go in HF Space Settings > Secrets) βββββββββ | |
| ENV FLASK_HOST=0.0.0.0 \ | |
| FLASK_PORT=7860 \ | |
| FLASK_DEBUG=false | |
| # ββ Run with Gunicorn (production-grade, matches your existing Space) ββββββββββ | |
| # run:app = the `app` object created in run.py | |
| CMD ["gunicorn", \ | |
| "--bind", "0.0.0.0:7860", \ | |
| "--workers", "1", \ | |
| "--worker-class", "sync", \ | |
| "--worker-tmp-dir", "/dev/shm", \ | |
| "--timeout", "180", \ | |
| "run:app"] | |