# Stage 1: Build React frontend
FROM node:22-slim AS frontend
WORKDIR /app
COPY frontend/package.json frontend/package-lock.json ./frontend/
RUN cd frontend && npm ci
COPY frontend/ ./frontend/
RUN cd frontend && npm run build
# Output lands in /app/web/dist (vite outDir: '../web/dist')

# Stage 2: Python runtime
FROM python:3.14-slim
WORKDIR /app

COPY . .
COPY --from=frontend /app/web/dist ./web/dist

ARG SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION}
RUN pip install --no-cache-dir .

EXPOSE 8000

# ANTHROPIC_API_KEY is provided at runtime via environment variable
CMD ["python", "-m", "firme_tutor"]
