# 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 requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

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

EXPOSE 8000

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