FROM oven/bun:1.3 AS builder
WORKDIR /app
COPY package.json bun.lock* ./
RUN bun install --frozen-lockfile
COPY . .
# Build both apps:
#   - dist/             main intelligence dashboard          (served at /)
#   - dist-editorial/   editorial review dashboard            (served at /editorial/*)
RUN bun run build && bun run build:editorial

FROM oven/bun:1.3-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/dist-editorial ./dist-editorial
COPY --from=builder /app/api ./api
COPY --from=builder /app/data ./data
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./

# Bun serves both static bundles + API on a single port
EXPOSE 3456
CMD ["bun", "api/server.ts"]
