mgbam commited on
Commit
09d09d3
·
verified ·
1 Parent(s): 7086216

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -53
Dockerfile CHANGED
@@ -1,56 +1,47 @@
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"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ############################
2
+ # 1. BASE & OS packages #
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
+ ############################
11
+ # 2. COPY dependency files #
12
+ ############################
13
  WORKDIR /app
14
+ COPY requirements.txt .
15
+ # holds ABI‑sensitive pins
16
+ COPY constraints.txt .
17
+
18
+ ############################
19
+ # 3. Two‑step pip install #
20
+ ############################
21
+ # 3‑A – first install ONLY the constrained binary wheels
22
+ RUN pip install --no-cache-dir -r requirements.txt -c constraints.txt
23
+
24
+ # 3‑B – guarantee final NumPy/SciPy still match the ABI
25
+ RUN pip install --no-cache-dir --force-reinstall "numpy==1.23.5" "scipy<1.11"
26
+
27
+ ############################
28
+ # 4. Copy application code #
29
+ ############################
30
+ COPY . /app
31
+
32
+ ############################
33
+ # 5. spaCy model download #
34
+ ############################
35
+ RUN python -m spacy validate && \
36
+ python -m spacy download en_core_web_sm
37
+
38
+ ############################
39
+ # 6. Streamlit launch cmd #
40
+ ############################
41
+ ENV PORT 7860
42
+ EXPOSE 7860
43
+
44
+ CMD streamlit run app.py \
45
+ --server.headless=true \
46
+ --server.address=0.0.0.0 \
47
+ --server.port=$PORT