# syntax=docker/dockerfile:1
# Build context is the repo ROOT (so the bun workspace resolves).

# ---- Build: install workspace deps and bundle the scanner ----
FROM oven/bun:1.3.14 AS build
WORKDIR /repo
COPY package.json bun.lock turbo.json ./
COPY packages/typescript-config/package.json ./packages/typescript-config/
COPY packages/eslint-config/package.json ./packages/eslint-config/
COPY apps/backend/package.json ./apps/backend/
COPY apps/frontend/package.json ./apps/frontend/
COPY apps/cli/package.json ./apps/cli/
RUN bun install --frozen-lockfile
COPY . .
RUN cd apps/cli && bun build src/index.ts --target bun --outdir dist

# ---- Runtime: run-to-completion scanner (tar ships in the Debian-based image) ----
FROM oven/bun:1.3.14-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /repo/apps/cli/dist ./dist
CMD ["bun", "dist/index.js"]
