Update Dockerfile
Browse files- Dockerfile +41 -46
Dockerfile
CHANGED
@@ -1,61 +1,56 @@
|
|
1 |
#########################
|
2 |
# BASE IMAGE #
|
3 |
#########################
|
4 |
-
FROM python:3.10-slim
|
5 |
|
6 |
#########################
|
7 |
-
# OS
|
8 |
#########################
|
9 |
RUN apt-get update && \
|
10 |
-
apt-get install -y --no-install-recommends
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# PYTHON LAYER #
|
15 |
-
#########################
|
16 |
-
# ▸ pin NumPy before spaCy to avoid the “dtype size changed” ABI error
|
17 |
-
# (spaCy 3.5.* was compiled against NumPy 1.23) ──■
|
18 |
-
RUN pip install --no-cache-dir numpy==1.23.5
|
19 |
-
|
20 |
-
# core scientific + web stack
|
21 |
-
RUN pip install --no-cache-dir \
|
22 |
-
spacy==3.5.2 \
|
23 |
-
transformers==4.53.0 \
|
24 |
-
huggingface-hub==0.33.1 \
|
25 |
-
scikit-learn==1.7.0 \
|
26 |
-
httpx==0.28.1 \
|
27 |
-
pandas==2.3.0 \
|
28 |
-
plotly==6.2.0 \
|
29 |
-
fpdf==1.7.2 \
|
30 |
-
streamlit==1.33.0 \
|
31 |
-
streamlit-agraph==0.0.45 \
|
32 |
-
networkx==3.4.2 \
|
33 |
-
xmltodict==0.14.2 \
|
34 |
-
feedparser==6.0.11 \
|
35 |
-
pydantic==2.11.7 \
|
36 |
-
openai==1.25.0 \
|
37 |
-
google-generativeai==0.5.4
|
38 |
-
|
39 |
-
#########################
|
40 |
-
# CODE #
|
41 |
-
#########################
|
42 |
-
WORKDIR /app
|
43 |
-
COPY . /app
|
44 |
|
45 |
#########################
|
46 |
-
#
|
47 |
#########################
|
|
|
|
|
|
|
|
|
|
|
48 |
RUN python -m spacy download en_core_web_sm
|
49 |
|
50 |
#########################
|
51 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
#########################
|
53 |
-
#
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
#
|
58 |
-
CMD
|
59 |
-
--server.headless=true \
|
60 |
-
--server.address=0.0.0.0 \
|
61 |
-
--server.port=$PORT
|
|
|
1 |
#########################
|
2 |
# BASE IMAGE #
|
3 |
#########################
|
4 |
+
FROM python:3.10-slim as builder
|
5 |
|
6 |
#########################
|
7 |
+
# OS-LEVEL DEPENDENCIES #
|
8 |
#########################
|
9 |
RUN apt-get update && \
|
10 |
+
apt-get install -y --no-install-recommends \
|
11 |
+
build-essential \
|
12 |
+
curl \
|
13 |
+
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
#########################
|
16 |
+
# PYTHON DEPENDENCIES #
|
17 |
#########################
|
18 |
+
# Create requirements layer first for better caching
|
19 |
+
COPY requirements.txt .
|
20 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
21 |
+
|
22 |
+
# Install spaCy model
|
23 |
RUN python -m spacy download en_core_web_sm
|
24 |
|
25 |
#########################
|
26 |
+
# APPLICATION SETUP #
|
27 |
+
#########################
|
28 |
+
WORKDIR /app
|
29 |
+
COPY . .
|
30 |
+
|
31 |
+
#########################
|
32 |
+
# RUNTIME CONFIG #
|
33 |
#########################
|
34 |
+
# Use multi-stage build for production
|
35 |
+
FROM python:3.10-slim as runtime
|
36 |
+
|
37 |
+
# Copy installed dependencies
|
38 |
+
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
39 |
+
COPY --from=builder /usr/local/bin /usr/local/bin
|
40 |
+
COPY --from=builder /app /app
|
41 |
+
|
42 |
+
WORKDIR /app
|
43 |
+
|
44 |
+
# Environment configuration
|
45 |
+
ENV PORT=7860 \
|
46 |
+
PYTHONUNBUFFERED=1 \
|
47 |
+
PYTHONPATH=/app
|
48 |
+
|
49 |
+
EXPOSE $PORT
|
50 |
+
|
51 |
+
# Health check
|
52 |
+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
53 |
+
CMD curl -f http://localhost:$PORT/health || exit 1
|
54 |
|
55 |
+
# Run with gunicorn for production
|
56 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:$PORT", "--workers", "4", "--threads", "2", "app:server"]
|
|
|
|
|
|