FROM node:20-alpine as builder

WORKDIR /app

RUN npm install -g pnpm@9

# Copy necessary files for workspace resolution
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages packages
COPY tooling tooling

# Install all dependencies
RUN pnpm install --frozen-lockfile

COPY . .

RUN pnpm build