# Step 1: Builder image FROM node:20-alpine AS builder RUN apk add --no-cache libc6-compat curl WORKDIR /app RUN corepack enable pnpm # Step 2: Install dependencies # We copy everything first because we have a .dockerignore # and we need the workspace structure for pnpm to work correctly COPY . . # Use a secret for NPM_TOKEN to authenticate with private registry RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \ --mount=type=secret,id=NPM_TOKEN \ export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN) && \ pnpm i --frozen-lockfile # Step 3: Build shared packages RUN pnpm --filter "./packages/*" -r build