Browse Source

fix: update pnpm installation method and version across Dockerfiles and configuration

Yuki Takei 1 week ago
parent
commit
33c844747b

+ 3 - 2
.devcontainer/app/devcontainer.json

@@ -7,8 +7,9 @@
   "workspaceFolder": "/workspace/growi",
 
   "features": {
-    "ghcr.io/devcontainers/features/node:1": {
-      "version": "24.14.0"
+    "ghcr.io/devcontainers/features/node:2": {
+      "version": "24",
+      "pnpmVersion": "11.1.1"
     },
     "ghcr.io/devcontainers/features/github-cli:1": {}
   },

+ 0 - 5
.devcontainer/app/postCreateCommand.sh

@@ -17,11 +17,6 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
 # Install Claude Code
 curl -fsSL https://claude.ai/install.sh | bash
 
-# Setup pnpm
-SHELL=bash pnpm setup
-eval "$(cat /home/vscode/.bashrc)"
-pnpm config set store-dir /workspace/.pnpm-store
-
 # Install turbo
 pnpm install turbo --global
 

+ 9 - 14
apps/app/docker/Dockerfile

@@ -2,7 +2,6 @@
 
 ARG NODE_VERSION=24
 ARG OPT_DIR="/opt"
-ARG PNPM_HOME="/root/.local/share/pnpm"
 
 ##
 ## base — official Node.js image with pnpm + turbo
@@ -10,17 +9,18 @@ ARG PNPM_HOME="/root/.local/share/pnpm"
 FROM node:24-bookworm AS base
 
 ARG OPT_DIR
-ARG PNPM_HOME
 
 WORKDIR $OPT_DIR
 
-# Install pnpm (standalone script, no version hardcoding)
-RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL=/bin/sh sh -
-ENV PNPM_HOME=$PNPM_HOME
-ENV PATH="$PNPM_HOME:$PNPM_HOME/bin:$PATH"
+# Activate corepack so the pnpm version pinned in the workspace package.json
+# "packageManager" field is used (avoids drift between Dockerfile and local/CI).
+RUN corepack enable
+ENV PNPM_HOME="/pnpm"
+ENV PATH="$PNPM_HOME:$PATH"
 
 # Install turbo globally
-RUN pnpm add turbo --global
+RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
+  pnpm add turbo --global
 
 
 ##
@@ -47,20 +47,15 @@ RUN turbo prune @growi/app @growi/pdf-converter --docker
 FROM base AS deps
 
 ARG OPT_DIR
-ARG PNPM_HOME
-
-ENV PNPM_HOME=$PNPM_HOME
-ENV PATH="$PNPM_HOME:$PNPM_HOME/bin:$PATH"
 
 WORKDIR $OPT_DIR
 
 # Copy only package manifests and lockfile for dependency caching
 COPY --from=pruner $OPT_DIR/out/json/ .
 
-# Separate store path keeps the BuildKit cache mount away from the pnpm bootstrap store.
 # --ignore-scripts: postinstall (prisma generate) needs full source, runs in builder stage.
-RUN --mount=type=cache,target=/root/.pnpm-store,sharing=locked \
-  pnpm install --frozen-lockfile --ignore-scripts --store-dir /root/.pnpm-store
+RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
+  pnpm install --frozen-lockfile --ignore-scripts
 
 
 ##

+ 7 - 16
apps/pdf-converter/docker/Dockerfile

@@ -2,7 +2,6 @@
 
 ARG NODE_VERSION=24
 ARG OPT_DIR="/opt"
-ARG PNPM_HOME="/root/.local/share/pnpm"
 
 ##
 ## base
@@ -10,22 +9,17 @@ ARG PNPM_HOME="/root/.local/share/pnpm"
 FROM node:${NODE_VERSION}-slim AS base
 
 ARG OPT_DIR
-ARG PNPM_HOME
 
 WORKDIR $OPT_DIR
 
-# install tools
-RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \
-  --mount=type=cache,target=/var/cache/apt,sharing=locked \
-  apt-get update && apt-get install -y ca-certificates wget --no-install-recommends
-
-# install pnpm
-RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" PNPM_VERSION="10.32.1" sh -
-ENV PNPM_HOME=$PNPM_HOME
+# Activate corepack so the pnpm version pinned in the workspace package.json
+# "packageManager" field is used (avoids drift between Dockerfile and local/CI).
+RUN corepack enable
+ENV PNPM_HOME="/pnpm"
 ENV PATH="$PNPM_HOME:$PATH"
 
 # install turbo
-RUN --mount=type=cache,target=$PNPM_HOME/store,sharing=locked \
+RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
   pnpm add turbo --global
 
 
@@ -35,15 +29,12 @@ RUN --mount=type=cache,target=$PNPM_HOME/store,sharing=locked \
 ##
 FROM base AS builder
 
-ENV PNPM_HOME=$PNPM_HOME
-ENV PATH="$PNPM_HOME:$PATH"
-
 WORKDIR $OPT_DIR
 
 COPY . .
 
-RUN --mount=type=cache,target=$PNPM_HOME/store,sharing=locked \
-  pnpm install ---frozen-lockfile
+RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
+  pnpm install --frozen-lockfile --ignore-scripts
 
 # build
 RUN turbo run clean

+ 8 - 6
apps/slackbot-proxy/docker/Dockerfile

@@ -11,14 +11,15 @@ ENV optDir="/opt"
 
 WORKDIR ${optDir}
 
-# install pnpm
-RUN apt-get update && apt-get install -y ca-certificates wget --no-install-recommends \
-  && wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" PNPM_VERSION="10.32.1" sh -
-ENV PNPM_HOME="/root/.local/share/pnpm"
+# Activate corepack so the pnpm version pinned in the workspace package.json
+# "packageManager" field is used (avoids drift between Dockerfile and local/CI).
+RUN corepack enable
+ENV PNPM_HOME="/pnpm"
 ENV PATH="$PNPM_HOME:$PATH"
 
 # install turbo
-RUN pnpm add turbo --global
+RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
+  pnpm add turbo --global
 
 
 
@@ -33,7 +34,8 @@ WORKDIR ${optDir}
 
 COPY . .
 
-RUN pnpm install --frozen-lockfile --ignore-scripts
+RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
+  pnpm install --frozen-lockfile --ignore-scripts
 
 # build
 RUN turbo run build --filter @growi/slackbot-proxy

+ 1 - 1
package.json

@@ -20,7 +20,7 @@
   "bugs": {
     "url": "https://github.com/growilabs/growi/issues"
   },
-  "packageManager": "pnpm@10.32.1",
+  "packageManager": "pnpm@11.1.1",
   "scripts": {
     "bootstrap": "pnpm install",
     "start": "pnpm run app:server",