# Matrx Files — standalone microservice image.
#
# Build from the MONOREPO ROOT (siblings resolve from the local workspace —
# the local matrx-utils/orm/connect versions lead what's on PyPI):
#   docker build -f packages/matrx-files/Dockerfile -t matrx-files .
#
# The image contains ONLY matrx-files + its declared dependencies. If the
# build ever needs anything else from the repo, the package is violating
# INDEPENDENCE.md — fix the package, not this file.
FROM python:3.13-slim

# tesseract: pytesseract OCR backend (same binary the CI gate installs).
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
    tesseract-ocr \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir uv

WORKDIR /app
# Declared local siblings first (leaf order), then the package itself.
COPY packages/matrx-utils   /deps/matrx-utils
COPY packages/matrx-connect /deps/matrx-connect
COPY packages/matrx-orm     /deps/matrx-orm
COPY packages/matrx-files   /app

RUN uv pip install --system /deps/matrx-utils /deps/matrx-connect /deps/matrx-orm \
    && uv pip install --system ".[standalone]"

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"]
