70 lines
2.4 KiB
Docker
70 lines
2.4 KiB
Docker
FROM python:3.11-slim-bookworm
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Switch apt to a faster mirror (Yandex) before installing. The default
|
|
# deb.debian.org Cloudflare CDN throttles to ~150 kB/s from some networks,
|
|
# stalling the build on gcc-12/cpp-12; Yandex serves consistently faster.
|
|
RUN sed -i 's|deb.debian.org|mirror.yandex.ru|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null \
|
|
|| sed -i 's|deb.debian.org|mirror.yandex.ru|g' /etc/apt/sources.list 2>/dev/null \
|
|
|| true
|
|
|
|
# System deps for OCRmyPDF + Tesseract (rus+eng) + Ghostscript + qpdf + image libs
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
--fix-missing -o Acquire::Retries=10 \
|
|
-o Acquire::http::Timeout=180 \
|
|
-o Acquire::https::Timeout=180 \
|
|
build-essential \
|
|
curl \
|
|
ca-certificates \
|
|
git \
|
|
ghostscript \
|
|
qpdf \
|
|
unpaper \
|
|
pngquant \
|
|
jbig2dec \
|
|
libxml2-dev \
|
|
libxslt1-dev \
|
|
libffi-dev \
|
|
libjpeg-dev \
|
|
libopenjp2-7 \
|
|
libtiff5-dev \
|
|
zlib1g-dev \
|
|
poppler-utils \
|
|
libmagic1 \
|
|
tesseract-ocr \
|
|
tesseract-ocr-eng \
|
|
tesseract-ocr-rus \
|
|
tesseract-ocr-osd \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the metadata + package payload BEFORE pip install. hatchling validates
|
|
# README.md and the [packages] entries (app, scripts) at editable-install time;
|
|
# missing files cause `Readme file does not exist` even with `pip install -e .`.
|
|
COPY pyproject.toml README.md alembic.ini /app/
|
|
COPY app /app/app
|
|
COPY scripts /app/scripts
|
|
|
|
# Local build: install the recognition engine from a pre-built wheel (the
|
|
# pinned git source lives in a private GitHub repo unreachable from the build
|
|
# container without credentials), then relax the pyproject pin to a version
|
|
# spec inside this layer only - the repo file stays untouched.
|
|
COPY docker/wheels /tmp/wheels
|
|
RUN pip install --upgrade pip wheel setuptools \
|
|
&& pip install /tmp/wheels/*.whl \
|
|
&& sed -i 's|"teamhub-document-recognition-engine @ git+[^"]*"|"teamhub-document-recognition-engine>=0.1.0"|' pyproject.toml \
|
|
&& pip install -e .
|
|
|
|
RUN mkdir -p /data/input /data/work
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|