Skip to content

Commit 1519669

Browse files
authored
fix: restore default npm cache and stop preinstalling pnpm (#307)
1 parent ef3d93e commit 1519669

10 files changed

Lines changed: 66 additions & 115 deletions

File tree

.github/workflows/release-node-playwright.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,14 @@ jobs:
248248
run: |
249249
docker run --rm ${{ fromJson(steps.prepare-tags.outputs.result).firstImageName }} sh -c '
250250
set -ex
251-
test "$(npm config get cache)" = "/pkg-cache/npm"
251+
test "$(npm config get cache)" = "$HOME/.npm"
252+
test ! -L "$HOME/.npm"
253+
test ! -e /pkg-cache/npm
254+
npm cache add is-number@7.0.0
255+
test -d "$HOME/.npm/_cacache"
256+
rm -rf "$HOME/.npm"
257+
test ! -e "$HOME/.npm"
258+
test -z "$(ls -A "$COREPACK_HOME")"
252259
pnpm store path | grep -q "^/pkg-cache/pnpm/store"
253260
test "$(pnpm config get node-linker)" = "hoisted"
254261
corepack pnpm@10 store path | grep -q "^/pkg-cache/pnpm/store"

.github/workflows/release-node-puppeteer.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,14 @@ jobs:
229229
run: |
230230
docker run --rm ${{ fromJson(steps.prepare-tags.outputs.result).firstImageName }} sh -c '
231231
set -ex
232-
test "$(npm config get cache)" = "/pkg-cache/npm"
232+
test "$(npm config get cache)" = "$HOME/.npm"
233+
test ! -L "$HOME/.npm"
234+
test ! -e /pkg-cache/npm
235+
npm cache add is-number@7.0.0
236+
test -d "$HOME/.npm/_cacache"
237+
rm -rf "$HOME/.npm"
238+
test ! -e "$HOME/.npm"
239+
test -z "$(ls -A "$COREPACK_HOME")"
233240
pnpm store path | grep -q "^/pkg-cache/pnpm/store"
234241
test "$(pnpm config get node-linker)" = "hoisted"
235242
corepack pnpm@10 store path | grep -q "^/pkg-cache/pnpm/store"

.github/workflows/release-node.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ jobs:
221221
run: |
222222
docker run --rm ${{ fromJson(steps.prepare-tags.outputs.result).firstImageName }} sh -c '
223223
set -ex
224-
test "$(npm config get cache)" = "/pkg-cache/npm"
224+
test "$(npm config get cache)" = "$HOME/.npm"
225+
test ! -L "$HOME/.npm"
226+
test ! -e /pkg-cache/npm
227+
npm cache add is-number@7.0.0
228+
test -d "$HOME/.npm/_cacache"
229+
rm -rf "$HOME/.npm"
230+
test ! -e "$HOME/.npm"
231+
test -z "$(ls -A "$COREPACK_HOME")"
225232
pnpm store path | grep -q "^/pkg-cache/pnpm/store"
226233
test "$(pnpm config get node-linker)" = "hoisted"
227234
corepack pnpm@10 store path | grep -q "^/pkg-cache/pnpm/store"

node-playwright-camoufox/Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ RUN apt update \
7171
# npm otherwise refuses to overwrite with corepack's shims.
7272
&& npm install -g --force corepack@latest \
7373
&& corepack enable \
74-
# Make pnpm >= 11 the version corepack provisions by default: pnpm 10 ignores the
75-
# PNPM_CONFIG_* env vars set below, so its store and cache would land in $HOME instead
76-
# of /pkg-cache. COREPACK_HOME is passed inline because its ENV is declared further down.
77-
&& COREPACK_HOME=/pkg-cache/corepack corepack install -g pnpm@latest \
7874
# pnpm 10 ignores the PNPM_CONFIG_* env vars set further down (they are pnpm >= 11 only),
7975
# and npm >= 11 warns on the equivalent npmrc keys / NPM_CONFIG_* vars, so mirror the
8076
# settings into pnpm's own global rc files, which only pnpm reads. This makes Actors that
@@ -86,7 +82,7 @@ RUN apt update \
8682
\
8783
# Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any
8884
# user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as.
89-
&& mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \
85+
&& mkdir -p /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache /pkg-cache/corepack \
9086
&& chmod -R 777 /pkg-cache \
9187
\
9288
# Cleanup time
@@ -96,11 +92,8 @@ RUN apt update \
9692
# This is needed to remove an annoying error message when running headful.
9793
&& mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \
9894
\
99-
# Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling
100-
# that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working.
101-
&& rm -rf /root/.npm /home/myuser/.npm \
102-
&& ln -s /pkg-cache/npm /root/.npm \
103-
&& ln -s /pkg-cache/npm /home/myuser/.npm
95+
# Clear npm caches populated during setup.
96+
&& rm -rf /root/.npm /home/myuser/.npm
10497

10598
# Run everything after as non-privileged user.
10699
USER myuser
@@ -118,15 +111,12 @@ ENV NODE_ENV=production
118111
# so we put back the old limit of 80kb, which seems to work just fine.
119112
ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000"
120113

121-
# Send every package-manager cache to a single, dedicated location instead of $HOME.
122-
# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating
123-
# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway
124-
# cache data and can be wiped or mounted as tmpfs without touching installed dependencies.
114+
# Keep yarn and pnpm caches under /pkg-cache so they can be removed after installation.
115+
# npm uses its default ~/.npm directory so existing cache cleanup commands still work.
125116
# COREPACK_HOME holds the package-manager versions corepack provisions on demand.
126117
# NOTE: only pnpm >= 11 reads the PNPM_CONFIG_* vars; pnpm 10 picks up the same settings
127118
# from the global pnpm rc files written to /root/.config/pnpm and /home/myuser/.config/pnpm.
128-
ENV NPM_CONFIG_CACHE=/pkg-cache/npm \
129-
YARN_CACHE_FOLDER=/pkg-cache/yarn \
119+
ENV YARN_CACHE_FOLDER=/pkg-cache/yarn \
130120
YARN_GLOBAL_FOLDER=/pkg-cache/yarn \
131121
PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \
132122
PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache \

node-playwright-chrome/Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ RUN apt update \
8686
# npm otherwise refuses to overwrite with corepack's shims.
8787
&& npm install -g --force corepack@latest \
8888
&& corepack enable \
89-
# Make pnpm >= 11 the version corepack provisions by default: pnpm 10 ignores the
90-
# PNPM_CONFIG_* env vars set below, so its store and cache would land in $HOME instead
91-
# of /pkg-cache. COREPACK_HOME is passed inline because its ENV is declared further down.
92-
&& COREPACK_HOME=/pkg-cache/corepack corepack install -g pnpm@latest \
9389
# pnpm 10 ignores the PNPM_CONFIG_* env vars set further down (they are pnpm >= 11 only),
9490
# and npm >= 11 warns on the equivalent npmrc keys / NPM_CONFIG_* vars, so mirror the
9591
# settings into pnpm's own global rc files, which only pnpm reads. This makes Actors that
@@ -101,7 +97,7 @@ RUN apt update \
10197
\
10298
# Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any
10399
# user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as.
104-
&& mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \
100+
&& mkdir -p /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache /pkg-cache/corepack \
105101
&& chmod -R 777 /pkg-cache \
106102
\
107103
# Cleanup time
@@ -111,11 +107,8 @@ RUN apt update \
111107
# This is needed to remove an annoying error message when running headful.
112108
&& mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \
113109
\
114-
# Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling
115-
# that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working.
116-
&& rm -rf /root/.npm /home/myuser/.npm \
117-
&& ln -s /pkg-cache/npm /root/.npm \
118-
&& ln -s /pkg-cache/npm /home/myuser/.npm
110+
# Clear npm caches populated during setup.
111+
&& rm -rf /root/.npm /home/myuser/.npm
119112

120113
# Run everything after as non-privileged user.
121114
USER myuser
@@ -133,15 +126,12 @@ ENV NODE_ENV=production
133126
# so we put back the old limit of 80kb, which seems to work just fine.
134127
ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000"
135128

136-
# Send every package-manager cache to a single, dedicated location instead of $HOME.
137-
# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating
138-
# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway
139-
# cache data and can be wiped or mounted as tmpfs without touching installed dependencies.
129+
# Keep yarn and pnpm caches under /pkg-cache so they can be removed after installation.
130+
# npm uses its default ~/.npm directory so existing cache cleanup commands still work.
140131
# COREPACK_HOME holds the package-manager versions corepack provisions on demand.
141132
# NOTE: only pnpm >= 11 reads the PNPM_CONFIG_* vars; pnpm 10 picks up the same settings
142133
# from the global pnpm rc files written to /root/.config/pnpm and /home/myuser/.config/pnpm.
143-
ENV NPM_CONFIG_CACHE=/pkg-cache/npm \
144-
YARN_CACHE_FOLDER=/pkg-cache/yarn \
134+
ENV YARN_CACHE_FOLDER=/pkg-cache/yarn \
145135
YARN_GLOBAL_FOLDER=/pkg-cache/yarn \
146136
PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \
147137
PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache \

node-playwright-firefox/Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ RUN apt update \
7676
# npm otherwise refuses to overwrite with corepack's shims.
7777
&& npm install -g --force corepack@latest \
7878
&& corepack enable \
79-
# Make pnpm >= 11 the version corepack provisions by default: pnpm 10 ignores the
80-
# PNPM_CONFIG_* env vars set below, so its store and cache would land in $HOME instead
81-
# of /pkg-cache. COREPACK_HOME is passed inline because its ENV is declared further down.
82-
&& COREPACK_HOME=/pkg-cache/corepack corepack install -g pnpm@latest \
8379
# pnpm 10 ignores the PNPM_CONFIG_* env vars set further down (they are pnpm >= 11 only),
8480
# and npm >= 11 warns on the equivalent npmrc keys / NPM_CONFIG_* vars, so mirror the
8581
# settings into pnpm's own global rc files, which only pnpm reads. This makes Actors that
@@ -91,7 +87,7 @@ RUN apt update \
9187
\
9288
# Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any
9389
# user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as.
94-
&& mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \
90+
&& mkdir -p /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache /pkg-cache/corepack \
9591
&& chmod -R 777 /pkg-cache \
9692
\
9793
# Cleanup time
@@ -101,11 +97,8 @@ RUN apt update \
10197
# This is needed to remove an annoying error message when running headful.
10298
&& mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \
10399
\
104-
# Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling
105-
# that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working.
106-
&& rm -rf /root/.npm /home/myuser/.npm \
107-
&& ln -s /pkg-cache/npm /root/.npm \
108-
&& ln -s /pkg-cache/npm /home/myuser/.npm
100+
# Clear npm caches populated during setup.
101+
&& rm -rf /root/.npm /home/myuser/.npm
109102

110103
# Run everything after as non-privileged user.
111104
USER myuser
@@ -123,15 +116,12 @@ ENV NODE_ENV=production
123116
# so we put back the old limit of 80kb, which seems to work just fine.
124117
ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000"
125118

126-
# Send every package-manager cache to a single, dedicated location instead of $HOME.
127-
# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating
128-
# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway
129-
# cache data and can be wiped or mounted as tmpfs without touching installed dependencies.
119+
# Keep yarn and pnpm caches under /pkg-cache so they can be removed after installation.
120+
# npm uses its default ~/.npm directory so existing cache cleanup commands still work.
130121
# COREPACK_HOME holds the package-manager versions corepack provisions on demand.
131122
# NOTE: only pnpm >= 11 reads the PNPM_CONFIG_* vars; pnpm 10 picks up the same settings
132123
# from the global pnpm rc files written to /root/.config/pnpm and /home/myuser/.config/pnpm.
133-
ENV NPM_CONFIG_CACHE=/pkg-cache/npm \
134-
YARN_CACHE_FOLDER=/pkg-cache/yarn \
124+
ENV YARN_CACHE_FOLDER=/pkg-cache/yarn \
135125
YARN_GLOBAL_FOLDER=/pkg-cache/yarn \
136126
PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \
137127
PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache \

node-playwright-webkit/Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ RUN apt update \
6565
# npm otherwise refuses to overwrite with corepack's shims.
6666
&& npm install -g --force corepack@latest \
6767
&& corepack enable \
68-
# Make pnpm >= 11 the version corepack provisions by default: pnpm 10 ignores the
69-
# PNPM_CONFIG_* env vars set below, so its store and cache would land in $HOME instead
70-
# of /pkg-cache. COREPACK_HOME is passed inline because its ENV is declared further down.
71-
&& COREPACK_HOME=/pkg-cache/corepack corepack install -g pnpm@latest \
7268
# pnpm 10 ignores the PNPM_CONFIG_* env vars set further down (they are pnpm >= 11 only),
7369
# and npm >= 11 warns on the equivalent npmrc keys / NPM_CONFIG_* vars, so mirror the
7470
# settings into pnpm's own global rc files, which only pnpm reads. This makes Actors that
@@ -80,7 +76,7 @@ RUN apt update \
8076
\
8177
# Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any
8278
# user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as.
83-
&& mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \
79+
&& mkdir -p /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache /pkg-cache/corepack \
8480
&& chmod -R 777 /pkg-cache \
8581
\
8682
# Cleanup time
@@ -90,11 +86,8 @@ RUN apt update \
9086
# This is needed to remove an annoying error message when running headful.
9187
&& mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \
9288
\
93-
# Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling
94-
# that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working.
95-
&& rm -rf /root/.npm /home/myuser/.npm \
96-
&& ln -s /pkg-cache/npm /root/.npm \
97-
&& ln -s /pkg-cache/npm /home/myuser/.npm
89+
# Clear npm caches populated during setup.
90+
&& rm -rf /root/.npm /home/myuser/.npm
9891

9992
# Run everything after as non-privileged user.
10093
USER myuser
@@ -112,15 +105,12 @@ ENV NODE_ENV=production
112105
# so we put back the old limit of 80kb, which seems to work just fine.
113106
ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000"
114107

115-
# Send every package-manager cache to a single, dedicated location instead of $HOME.
116-
# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating
117-
# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway
118-
# cache data and can be wiped or mounted as tmpfs without touching installed dependencies.
108+
# Keep yarn and pnpm caches under /pkg-cache so they can be removed after installation.
109+
# npm uses its default ~/.npm directory so existing cache cleanup commands still work.
119110
# COREPACK_HOME holds the package-manager versions corepack provisions on demand.
120111
# NOTE: only pnpm >= 11 reads the PNPM_CONFIG_* vars; pnpm 10 picks up the same settings
121112
# from the global pnpm rc files written to /root/.config/pnpm and /home/myuser/.config/pnpm.
122-
ENV NPM_CONFIG_CACHE=/pkg-cache/npm \
123-
YARN_CACHE_FOLDER=/pkg-cache/yarn \
113+
ENV YARN_CACHE_FOLDER=/pkg-cache/yarn \
124114
YARN_GLOBAL_FOLDER=/pkg-cache/yarn \
125115
PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \
126116
PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache \

node-playwright/Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ RUN apt update \
8888
# npm otherwise refuses to overwrite with corepack's shims.
8989
&& npm install -g --force corepack@latest \
9090
&& corepack enable \
91-
# Make pnpm >= 11 the version corepack provisions by default: pnpm 10 ignores the
92-
# PNPM_CONFIG_* env vars set below, so its store and cache would land in $HOME instead
93-
# of /pkg-cache. COREPACK_HOME is passed inline because its ENV is declared further down.
94-
&& COREPACK_HOME=/pkg-cache/corepack corepack install -g pnpm@latest \
9591
# pnpm 10 ignores the PNPM_CONFIG_* env vars set further down (they are pnpm >= 11 only),
9692
# and npm >= 11 warns on the equivalent npmrc keys / NPM_CONFIG_* vars, so mirror the
9793
# settings into pnpm's own global rc files, which only pnpm reads. This makes Actors that
@@ -103,7 +99,7 @@ RUN apt update \
10399
\
104100
# Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any
105101
# user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as.
106-
&& mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \
102+
&& mkdir -p /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache /pkg-cache/corepack \
107103
&& chmod -R 777 /pkg-cache \
108104
\
109105
# Cleanup time
@@ -113,11 +109,8 @@ RUN apt update \
113109
# This is needed to remove an annoying error message when running headful.
114110
&& mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \
115111
\
116-
# Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling
117-
# that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working.
118-
&& rm -rf /root/.npm /home/myuser/.npm \
119-
&& ln -s /pkg-cache/npm /root/.npm \
120-
&& ln -s /pkg-cache/npm /home/myuser/.npm
112+
# Clear npm caches populated during setup.
113+
&& rm -rf /root/.npm /home/myuser/.npm
121114

122115
# Run everything after as non-privileged user.
123116
USER myuser
@@ -135,15 +128,12 @@ ENV NODE_ENV=production
135128
# so we put back the old limit of 80kb, which seems to work just fine.
136129
ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000"
137130

138-
# Send every package-manager cache to a single, dedicated location instead of $HOME.
139-
# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating
140-
# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway
141-
# cache data and can be wiped or mounted as tmpfs without touching installed dependencies.
131+
# Keep yarn and pnpm caches under /pkg-cache so they can be removed after installation.
132+
# npm uses its default ~/.npm directory so existing cache cleanup commands still work.
142133
# COREPACK_HOME holds the package-manager versions corepack provisions on demand.
143134
# NOTE: only pnpm >= 11 reads the PNPM_CONFIG_* vars; pnpm 10 picks up the same settings
144135
# from the global pnpm rc files written to /root/.config/pnpm and /home/myuser/.config/pnpm.
145-
ENV NPM_CONFIG_CACHE=/pkg-cache/npm \
146-
YARN_CACHE_FOLDER=/pkg-cache/yarn \
136+
ENV YARN_CACHE_FOLDER=/pkg-cache/yarn \
147137
YARN_GLOBAL_FOLDER=/pkg-cache/yarn \
148138
PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \
149139
PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache \

0 commit comments

Comments
 (0)