FROM node:20-alpine AS base RUN apk add --no-cache libc6-compat curl WORKDIR /app # Enable pnpm RUN corepack enable pnpm # Copy root configurations COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc* ./ # Copy all package.json files to allow pnpm install to be cached COPY packages/*/package.json ./packages/ COPY apps/*/package.json ./apps/ # Install dependencies for the entire monorepo RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \ pnpm i --frozen-lockfile # Copy the rest of the source code COPY . . # Post-install/Build shared packages if needed RUN pnpm -r build --filter="./packages/*"