File size: 1,331 Bytes
6db4426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426c1d8
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
# Use an official Python runtime as a parent image
FROM python:3.10-slim

# Prevent Python from writing .pyc files to disc and enable unbuffered output
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set the working directory
WORKDIR /app

# Install git (required by some HF models) and basic system tools
RUN apt-get update && apt-get install -y git && apt-get clean

# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Pre-download NER model
RUN python -c "from transformers import AutoTokenizer, AutoModelForTokenClassification; \
               model = AutoModelForTokenClassification.from_pretrained('Davlan/bert-base-multilingual-cased-ner-hrl'); \
               tokenizer = AutoTokenizer.from_pretrained('Davlan/bert-base-multilingual-cased-ner-hrl'); \
               model.save_pretrained('./model'); tokenizer.save_pretrained('./model')"

# Pre-download SentenceTransformer model
RUN python -c "from sentence_transformers import SentenceTransformer; \
               model = SentenceTransformer('paraphrase-multilingual-mpnet-base-v2'); \
               model.save('./sbert_model')"

# Copy app code into container
COPY . .

# Expose port
EXPOSE 8000

# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]