# Thermograph frontend: server-rendered content pages, the interactive tool's
# SPA shells, and every static asset. Split from the monorepo (repo-split
# Stage 7). No migrations, no DB, no pre-boot logic -- a plain shell-form CMD
# is enough (unlike backend, no separate entrypoint script needed).
FROM python:3.12-slim

RUN apt-get update \
    && apt-get install -y --no-install-recommends curl \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

COPY . /app/

RUN useradd --system --create-home --uid 10001 thermograph \
    && chown -R thermograph:thermograph /app

USER thermograph
WORKDIR /app

ENV PORT=8080 \
    THERMOGRAPH_BASE=/ \
    PYTHONUNBUFFERED=1

EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
    CMD curl -fsS http://127.0.0.1:${PORT}/healthz || exit 1

CMD uvicorn app:app --host 0.0.0.0 --port ${PORT}
