# Stage 1: build React editor UI
FROM node:20-alpine AS editor-build
WORKDIR /build
COPY editor-ui/package*.json ./
RUN npm ci --prefer-offline
COPY editor-ui/ ./
RUN npm run build

# Stage 2: Python app
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
COPY --from=editor-build /build/dist ./editor-ui/dist
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
