File size: 1,313 Bytes
4c114c1
 
 
 
 
 
ec3436e
4c114c1
 
 
 
 
 
 
 
 
 
 
 
0dea19b
 
4c114c1
 
 
 
 
bb7b11b
 
 
 
4c114c1
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM node:20-slim AS frontend-builder

WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./

RUN npm run build

FROM python:3.11-slim

# gcc is required to compile hdbscan from source
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc g++ nodejs npm nginx curl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt .
# Install CPU-only torch first for HF Space (CPU-only environment)
RUN pip install --no-cache-dir torch==2.2.0+cpu --extra-index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir -r requirements.txt

COPY nlp_core/ ./nlp_core/
COPY adapters/ ./adapters/

# Pre-download NER model weights from HuggingFace Hub at build time
# so the first request is fast (no 677MB download on startup)
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('Nomio4640/ner-mongolian')"

COPY --from=frontend-builder /app/frontend/.next ./frontend/.next
COPY --from=frontend-builder /app/frontend/public ./frontend/public
COPY --from=frontend-builder /app/frontend/package*.json ./frontend/
COPY --from=frontend-builder /app/frontend/node_modules ./frontend/node_modules

COPY nginx.conf /etc/nginx/sites-available/default

EXPOSE 7860

COPY start.sh .
RUN chmod +x start.sh

CMD ["./start.sh"]