# Matrx Files — standalone microservice image.
#
# Installs ENTIRELY from PyPI (all matrx-* deps are published; a bare
# `uv pip install matrx-files[standalone]` is proven by the independence
# gate + a PyPI-only boot test). Build from anywhere:
#   docker build -t matrx-files packages/matrx-files
# Pin the version at build time for reproducible deploys:
#   docker build --build-arg MATRX_FILES_VERSION==0.1.0 -t matrx-files:0.1.0 packages/matrx-files
FROM python:3.13-slim

# System binaries:
#   tesseract-ocr           — pytesseract OCR backend (same binary the CI gate installs).
#   libreoffice-{writer,calc,impress} + -core — the Office codec's LibreOffice lane:
#       reads legacy .doc/.ppt/.xls (→ OpenXML) and renders any Office doc → PDF
#       for page-1 thumbnails. --no-install-recommends keeps the three apps
#       (~450 MB) instead of the full ~1 GB suite; the codec degrades to
#       pure-python (OpenXML only) if these are ever absent.
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
    tesseract-ocr \
    libreoffice-core \
    libreoffice-writer \
    libreoffice-calc \
    libreoffice-impress \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir uv

ARG MATRX_FILES_VERSION=""
RUN uv pip install --system "matrx-files[standalone]${MATRX_FILES_VERSION}"

ENV MATRX_FILES_BASE_DIR=/data/matrx-files
EXPOSE 8080
CMD ["uvicorn", "matrx_files.standalone.app:create_app", "--factory", "--host", "0.0.0.0", "--port", "8080"]
