ocr_annotator/Dockerfile
2026-06-24 13:01:26 +04:00

20 lines
734 B
Docker

FROM python:3.11-slim
WORKDIR /app
RUN pip install --no-cache-dir flask==3.0.3 gunicorn==22.0.0
# TrOCR auto-labeling deps (CPU build of torch keeps the image smaller).
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir transformers pillow sentencepiece
# Persist the downloaded HuggingFace model in the mounted /data volume.
ENV HF_HOME=/data/hf_cache
COPY app.py .
COPY templates/ templates/
EXPOSE 5000
# Single worker + threads: the TrOCR model is loaded once per process and the
# auto-label job tracks progress in-process, so we keep one worker.
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "1", "--threads", "4", "--timeout", "120", "app:app"]