translate / Dockerfile
devusman's picture
update
3f9181a
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"]