File size: 813 Bytes
3f9181a
d9f9373
3f9181a
 
d9f9373
3f9181a
05e7f60
3f9181a
 
05e7f60
3f9181a
 
05e7f60
3f9181a
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# system deps for sentencepiece & build
RUN apt-get update && apt-get install -y git build-essential

# copy code
COPY . /app

# install python deps
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Ensure model is downloaded at build-time to speed cold-start (optional)
# You can uncomment the following to pre-cache HF model in the image:
RUN python -c "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; AutoTokenizer.from_pretrained('Helsinki-NLP/opus-mt-en-ar'); AutoModelForSeq2SeqLM.from_pretrained('Helsinki-NLP/opus-mt-en-ar')"

# Use gunicorn for production inside Space
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app", "--workers", "1", "--threads", "4", "--timeout", "300"]