############################################################ # 1 ─ Base image & build‑tools ############################################################ FROM python:3.10-slim RUN apt-get update && \ apt-get install -y --no-install-recommends build-essential curl && \ rm -rf /var/lib/apt/lists/* WORKDIR /app ############################################################ # 2 ─ Copy dependency manifests ############################################################ # requirements.txt must already live at repo root COPY requirements.txt . # Create a constraints file **inside** the image so the build # never fails when it’s missing in the repo. # These pins guarantee spaCy/scispaCy keep working with NumPy. RUN printf 'numpy==1.23.5\nscipy<1.11\nspacy<3.5\n' > /tmp/constraints.txt ############################################################ # 3 ─ Install Python dependencies deterministically ############################################################ # First pass obeys the constraints file RUN pip install --no-cache-dir -r requirements.txt -c /tmp/constraints.txt # Belt‑and‑braces: re‑install NumPy & SciPy pins in case # a future transitive dep overrides them. RUN pip install --no-cache-dir --force-reinstall "numpy==1.23.5" "scipy<1.11" ############################################################ # 4 ─ Copy application source code ############################################################ COPY . /app ############################################################ # 5 ─ Validate wheels & fetch minimal spaCy model ############################################################ RUN python -m spacy validate && \ python -m spacy download en_core_web_sm ############################################################ # 6 ─ Expose the correct port & start Streamlit ############################################################ ENV PORT=7860 EXPOSE 7860 CMD streamlit run app.py \ --server.headless=true \ --server.address=0.0.0.0 \ --server.port=$PORT