FROM node:20-slim

WORKDIR /app

# Install git for cloning
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate

# Copy the monorepo structure (minimized for runner)
COPY pnpm-workspace.yaml package.json ./
COPY packages/types ./packages/types
COPY packages/engine ./packages/engine
COPY packages/rules ./packages/rules
COPY apps/cli ./apps/cli

# Install dependencies for the CLI and engine
RUN pnpm install --filter owstra...

# Set up the command to run a scan and report back
ENTRYPOINT ["pnpm", "--filter", "owstra", "run", "shield", "scan"]
