Update Dockerfile
Browse files- Dockerfile +44 -10
Dockerfile
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
#
|
|
|
|
|
|
|
|
|
|
| 6 |
COPY requirements.txt .
|
| 7 |
-
COPY constraints.txt .
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
############################################################
|
| 2 |
+
# 1 ─ Base image & build‑tools
|
| 3 |
+
############################################################
|
| 4 |
FROM python:3.10-slim
|
| 5 |
|
| 6 |
+
RUN apt-get update && \
|
| 7 |
+
apt-get install -y --no-install-recommends build-essential curl && \
|
| 8 |
+
rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
+
############################################################
|
| 13 |
+
# 2 ─ Copy dependency manifests
|
| 14 |
+
############################################################
|
| 15 |
+
# requirements.txt must already live at repo root
|
| 16 |
COPY requirements.txt .
|
|
|
|
| 17 |
|
| 18 |
+
# Create a constraints file **inside** the image so the build
|
| 19 |
+
# never fails when it’s missing in the repo.
|
| 20 |
+
# These pins guarantee spaCy/scispaCy keep working with NumPy.
|
| 21 |
+
RUN printf 'numpy==1.23.5\nscipy<1.11\nspacy<3.5\n' > /tmp/constraints.txt
|
| 22 |
+
|
| 23 |
+
############################################################
|
| 24 |
+
# 3 ─ Install Python dependencies deterministically
|
| 25 |
+
############################################################
|
| 26 |
+
# First pass obeys the constraints file
|
| 27 |
+
RUN pip install --no-cache-dir -r requirements.txt -c /tmp/constraints.txt
|
| 28 |
+
|
| 29 |
+
# Belt‑and‑braces: re‑install NumPy & SciPy pins in case
|
| 30 |
+
# a future transitive dep overrides them.
|
| 31 |
+
RUN pip install --no-cache-dir --force-reinstall "numpy==1.23.5" "scipy<1.11"
|
| 32 |
+
|
| 33 |
+
############################################################
|
| 34 |
+
# 4 ─ Copy application source code
|
| 35 |
+
############################################################
|
| 36 |
+
COPY . /app
|
| 37 |
|
| 38 |
+
############################################################
|
| 39 |
+
# 5 ─ Validate wheels & fetch minimal spaCy model
|
| 40 |
+
############################################################
|
| 41 |
+
RUN python -m spacy validate && \
|
| 42 |
+
python -m spacy download en_core_web_sm
|
| 43 |
|
| 44 |
+
############################################################
|
| 45 |
+
# 6 ─ Expose the correct port & start Streamlit
|
| 46 |
+
############################################################
|
| 47 |
+
ENV PORT=7860
|
| 48 |
+
EXPOSE 7860
|
| 49 |
|
| 50 |
+
CMD streamlit run app.py \
|
| 51 |
+
--server.headless=true \
|
| 52 |
+
--server.address=0.0.0.0 \
|
| 53 |
+
--server.port=$PORT
|