# syntax=docker/dockerfile:1.7 # Build container for the Farient Brand Review API. # # Includes LibreOffice + Poppler + a font bundle so the headless slide # rendering pipeline (task fn-1-sya.4) has everything it needs at runtime. # Python deps are managed reproducibly via `uv` and the committed `uv.lock`. FROM python:3.12-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ UV_LINK_MODE=copy \ UV_COMPILE_BYTECODE=1 \ UV_PROJECT_ENVIRONMENT=/app/.venv \ PATH="/app/.venv/bin:/root/.local/bin:${PATH}" # System deps: # libreoffice-impress -> soffice headless for .pptx -> .pdf # poppler-utils -> pdf2image (PDF -> PNG) # fonts-liberation -> Arial / Times / Courier metric-compatibles # fonts-crosextra-carlito -> Calibri metric-compatible (PowerPoint body font) # fonts-crosextra-caladea -> Cambria metric-compatible (PowerPoint heading) # fonts-dejavu -> broad latin coverage # fonts-noto-cjk -> prevents silent glyph substitution (visual # fidelity for fn-1-sya.4) # ca-certificates+curl -> needed to fetch the uv installer RUN apt-get update \ && apt-get install -y --no-install-recommends \ libreoffice-impress \ poppler-utils \ fonts-liberation \ fonts-crosextra-carlito \ fonts-crosextra-caladea \ fonts-dejavu \ fonts-noto-cjk \ ca-certificates \ curl \ && rm -rf /var/lib/apt/lists/* # Install uv via the official installer. RUN curl -LsSf https://astral.sh/uv/install.sh | sh WORKDIR /app # Copy lockfile + project metadata first so the dep layer caches. COPY pyproject.toml uv.lock ./ RUN uv sync --frozen --no-dev # Pre-warm soffice once at build time so the first runtime invocation is fast # and any font / profile init failures surface during `docker build`, not in # production. RUN mkdir -p /tmp/prewarm \ && printf "Pre-warm" > /tmp/prewarm/seed.txt \ && soffice --headless \ -env:UserInstallation=file:///tmp/lo_prewarm \ --convert-to pdf \ --outdir /tmp/prewarm \ /tmp/prewarm/seed.txt \ && rm -rf /tmp/prewarm /tmp/lo_prewarm # Now copy the rest of the source. COPY . . EXPOSE 8000 CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]