# Stage 1: Build React frontend
FROM node:20-alpine AS frontend-build
WORKDIR /app/web
COPY web/package*.json ./
RUN npm ci --silent
COPY web/ .
RUN npm run build

# Stage 2: Python runtime + serve everything
FROM python:3.11-slim AS runtime
WORKDIR /app
ENV DHARA_ENV=production

COPY pyproject.toml README.md ./
RUN pip install --no-cache-dir .

COPY dhara/ ./dhara/
COPY api/ ./api/
COPY --from=frontend-build /app/web/dist ./web/dist

EXPOSE 8080
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8080"]
