FROM python:3.12-slim
RUN sed -i "s|http://deb.debian.org|https://deb.debian.org|g" /etc/apt/sources.list.d/debian.sources && apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 install -y --no-install-recommends git libgl1 libglib2.0-0 && rm -rf /var/lib/apt/lists/*
WORKDIR /runtime
COPY requirements.lock ./
RUN pip install --no-cache-dir -r requirements.lock
COPY patch_task_storage.py ./
RUN python patch_task_storage.py
# Provision supported TTF during image build; no runtime download or OCR model loading.
RUN python -c 'from babeldoc.assets.assets import get_font_and_metadata; import shutil; p,_=get_font_and_metadata("SourceHanSerifCN-Regular.ttf"); shutil.copy(p,"/runtime/SourceHanSerifCN-Regular.ttf")'
COPY runner.py server.py health.py limits.py ./
RUN useradd --system --uid 10001 --create-home translator
USER translator
ENV PDF_TRANSLATION_FONT_PATH=/runtime/SourceHanSerifCN-Regular.ttf
EXPOSE 8091
CMD ["python", "server.py"]
