diff --git a/packages/infra/docker/Dockerfile.gatekeeper b/packages/infra/docker/Dockerfile.gatekeeper index 74a9b37..07966fb 100644 --- a/packages/infra/docker/Dockerfile.gatekeeper +++ b/packages/infra/docker/Dockerfile.gatekeeper @@ -4,15 +4,24 @@ RUN apk add --no-cache libc6-compat curl WORKDIR /app RUN corepack enable pnpm -# Copy source (honoring .dockerignore) -COPY . . +# Copy manifest files specifically for better layer caching +COPY pnpm-lock.yaml pnpm-workspace.yaml package.json .npmrc ./ +COPY packages/gatekeeper/package.json ./packages/gatekeeper/package.json +COPY packages/next-utils/package.json ./packages/next-utils/package.json +COPY packages/eslint-config/package.json ./packages/eslint-config/package.json +COPY packages/next-config/package.json ./packages/next-config/package.json +COPY packages/tsconfig/package.json ./packages/tsconfig/package.json -# Use a secret for NPM_TOKEN to authenticate with private registry -RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \ +# Use a secret for NPM_TOKEN and a cache mount for the pnpm store +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ --mount=type=secret,id=NPM_TOKEN \ export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN) && \ + pnpm config set store-dir /pnpm/store && \ pnpm i --frozen-lockfile +# Copy the rest of the source +COPY . . + # Build Gatekeeper and its dependencies RUN pnpm --filter @mintel/gatekeeper... build RUN mkdir -p packages/gatekeeper/public