ZeroNinerOne commited on
Commit
6928cd4
·
verified ·
1 Parent(s): 0e0f222

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +4 -20
  2. build_spacy.py +8 -0
Dockerfile CHANGED
@@ -1,32 +1,16 @@
1
  FROM python:3.12-slim
2
 
3
- # System deps needed for spaCy, chromadb, bcrypt
4
- RUN apt-get update && apt-get install -y \
5
- gcc g++ git curl \
6
- && rm -rf /var/lib/apt/lists/*
7
 
8
  WORKDIR /app
9
 
10
- # Install Python deps first (cached layer)
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
- # Copy app code
15
  COPY . .
16
 
17
- # Build spaCy model at image build time
18
- RUN python3 -c "
19
- from pathlib import Path
20
- import spacy
21
- from spacy.lang.en import English
22
- nlp = English()
23
- nlp.add_pipe('sentencizer')
24
- Path('en_model').mkdir(exist_ok=True)
25
- nlp.to_disk('en_model')
26
- print('spaCy model built')
27
- "
28
-
29
- # HuggingFace Spaces runs as port 7860
30
  ENV PORT=7860
31
  ENV HOST=0.0.0.0
32
  ENV WORKERS=1
@@ -35,4 +19,4 @@ ENV NEUROCHECK_DB=/tmp/neurocheck.db
35
 
36
  EXPOSE 7860
37
 
38
- CMD ["python3", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
 
1
  FROM python:3.12-slim
2
 
3
+ RUN apt-get update && apt-get install -y gcc g++ git && rm -rf /var/lib/apt/lists/*
 
 
 
4
 
5
  WORKDIR /app
6
 
 
7
  COPY requirements.txt .
8
  RUN pip install --no-cache-dir -r requirements.txt
9
 
 
10
  COPY . .
11
 
12
+ RUN python3 build_spacy.py
13
+
 
 
 
 
 
 
 
 
 
 
 
14
  ENV PORT=7860
15
  ENV HOST=0.0.0.0
16
  ENV WORKERS=1
 
19
 
20
  EXPOSE 7860
21
 
22
+ CMD ["python3", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]
build_spacy.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import spacy
3
+ from spacy.lang.en import English
4
+ nlp = English()
5
+ nlp.add_pipe("sentencizer")
6
+ Path("en_model").mkdir(exist_ok=True)
7
+ nlp.to_disk("en_model")
8
+ print("spaCy model built OK")