diff --git a/node-playwright-camoufox/Dockerfile b/node-playwright-camoufox/Dockerfile index eaaeab77..48b60657 100644 --- a/node-playwright-camoufox/Dockerfile +++ b/node-playwright-camoufox/Dockerfile @@ -66,13 +66,28 @@ RUN apt update \ # Globally disable the update-notifier. && npm config --global set update-notifier false \ \ + # Install the latest Corepack so Actors can opt into yarn or pnpm; `enable` drops the shims into the global bin. + && npm install -g corepack@latest \ + && corepack enable \ + \ + # Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any + # user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as. + && mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \ + && chmod -R 777 /pkg-cache \ + \ # Cleanup time && rm -rf /var/lib/apt/lists/* \ && rm -rf /src/*.deb \ && apt clean -y && apt autoremove -y \ && rm -rf /root/.npm \ # This is needed to remove an annoying error message when running headful. - && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix + && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \ + \ + # Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling + # that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working. + && rm -rf /root/.npm /home/myuser/.npm \ + && ln -s /pkg-cache/npm /root/.npm \ + && ln -s /pkg-cache/npm /home/myuser/.npm # Run everything after as non-privileged user. USER myuser @@ -90,6 +105,22 @@ ENV NODE_ENV=production # so we put back the old limit of 80kb, which seems to work just fine. ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000" +# Send every package-manager cache to a single, dedicated location instead of $HOME. +# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating +# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway +# cache data and can be wiped or mounted as tmpfs without touching installed dependencies. +ENV NPM_CONFIG_CACHE=/pkg-cache/npm \ + YARN_CACHE_FOLDER=/pkg-cache/yarn \ + YARN_GLOBAL_FOLDER=/pkg-cache/yarn \ + PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \ + PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache + +# Make pnpm and yarn use a flat, npm-style node_modules instead of their non-node_modules +# defaults (pnpm's symlinked store, yarn Berry's Plug'n'Play), so installed dependencies are +# plain copies that any tooling can resolve without symlinks or a PnP loader. +ENV PNPM_CONFIG_NODE_LINKER=hoisted \ + YARN_NODE_LINKER=node-modules + # Install default dependencies, print versions of everything RUN npm --quiet set progress=false \ \ diff --git a/node-playwright-chrome/Dockerfile b/node-playwright-chrome/Dockerfile index 5c073a7a..1e6153fa 100644 --- a/node-playwright-chrome/Dockerfile +++ b/node-playwright-chrome/Dockerfile @@ -81,13 +81,28 @@ RUN apt update \ # Globally disable the update-notifier. && npm config --global set update-notifier false \ \ + # Install the latest Corepack so Actors can opt into yarn or pnpm; `enable` drops the shims into the global bin. + && npm install -g corepack@latest \ + && corepack enable \ + \ + # Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any + # user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as. + && mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \ + && chmod -R 777 /pkg-cache \ + \ # Cleanup time && rm -rf /var/lib/apt/lists/* \ && rm -rf /src/*.deb \ && apt clean -y && apt autoremove -y \ && rm -rf /root/.npm \ # This is needed to remove an annoying error message when running headful. - && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix + && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \ + \ + # Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling + # that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working. + && rm -rf /root/.npm /home/myuser/.npm \ + && ln -s /pkg-cache/npm /root/.npm \ + && ln -s /pkg-cache/npm /home/myuser/.npm # Run everything after as non-privileged user. USER myuser @@ -105,6 +120,22 @@ ENV NODE_ENV=production # so we put back the old limit of 80kb, which seems to work just fine. ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000" +# Send every package-manager cache to a single, dedicated location instead of $HOME. +# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating +# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway +# cache data and can be wiped or mounted as tmpfs without touching installed dependencies. +ENV NPM_CONFIG_CACHE=/pkg-cache/npm \ + YARN_CACHE_FOLDER=/pkg-cache/yarn \ + YARN_GLOBAL_FOLDER=/pkg-cache/yarn \ + PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \ + PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache + +# Make pnpm and yarn use a flat, npm-style node_modules instead of their non-node_modules +# defaults (pnpm's symlinked store, yarn Berry's Plug'n'Play), so installed dependencies are +# plain copies that any tooling can resolve without symlinks or a PnP loader. +ENV PNPM_CONFIG_NODE_LINKER=hoisted \ + YARN_NODE_LINKER=node-modules + # Install default dependencies, print versions of everything RUN npm --quiet set progress=false \ && npm install --omit=dev --omit=optional --no-package-lock --prefer-online \ diff --git a/node-playwright-firefox/Dockerfile b/node-playwright-firefox/Dockerfile index 594c52ed..4a61631b 100644 --- a/node-playwright-firefox/Dockerfile +++ b/node-playwright-firefox/Dockerfile @@ -71,13 +71,28 @@ RUN apt update \ # Globally disable the update-notifier. && npm config --global set update-notifier false \ \ + # Install the latest Corepack so Actors can opt into yarn or pnpm; `enable` drops the shims into the global bin. + && npm install -g corepack@latest \ + && corepack enable \ + \ + # Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any + # user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as. + && mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \ + && chmod -R 777 /pkg-cache \ + \ # Cleanup time && rm -rf /var/lib/apt/lists/* \ && rm -rf /src/*.deb \ && apt clean -y && apt autoremove -y \ && rm -rf /root/.npm \ # This is needed to remove an annoying error message when running headful. - && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix + && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \ + \ + # Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling + # that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working. + && rm -rf /root/.npm /home/myuser/.npm \ + && ln -s /pkg-cache/npm /root/.npm \ + && ln -s /pkg-cache/npm /home/myuser/.npm # Run everything after as non-privileged user. USER myuser @@ -95,6 +110,22 @@ ENV NODE_ENV=production # so we put back the old limit of 80kb, which seems to work just fine. ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000" +# Send every package-manager cache to a single, dedicated location instead of $HOME. +# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating +# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway +# cache data and can be wiped or mounted as tmpfs without touching installed dependencies. +ENV NPM_CONFIG_CACHE=/pkg-cache/npm \ + YARN_CACHE_FOLDER=/pkg-cache/yarn \ + YARN_GLOBAL_FOLDER=/pkg-cache/yarn \ + PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \ + PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache + +# Make pnpm and yarn use a flat, npm-style node_modules instead of their non-node_modules +# defaults (pnpm's symlinked store, yarn Berry's Plug'n'Play), so installed dependencies are +# plain copies that any tooling can resolve without symlinks or a PnP loader. +ENV PNPM_CONFIG_NODE_LINKER=hoisted \ + YARN_NODE_LINKER=node-modules + # Install default dependencies, print versions of everything RUN npm --quiet set progress=false \ && npm install --omit=dev --omit=optional --no-package-lock --prefer-online \ diff --git a/node-playwright-webkit/Dockerfile b/node-playwright-webkit/Dockerfile index 62bf8e71..3c26642c 100644 --- a/node-playwright-webkit/Dockerfile +++ b/node-playwright-webkit/Dockerfile @@ -60,13 +60,28 @@ RUN apt update \ # Globally disable the update-notifier. && npm config --global set update-notifier false \ \ + # Install the latest Corepack so Actors can opt into yarn or pnpm; `enable` drops the shims into the global bin. + && npm install -g corepack@latest \ + && corepack enable \ + \ + # Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any + # user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as. + && mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \ + && chmod -R 777 /pkg-cache \ + \ # Cleanup time && rm -rf /var/lib/apt/lists/* \ && rm -rf /src/*.deb \ && apt clean -y && apt autoremove -y \ && rm -rf /root/.npm \ # This is needed to remove an annoying error message when running headful. - && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix + && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \ + \ + # Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling + # that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working. + && rm -rf /root/.npm /home/myuser/.npm \ + && ln -s /pkg-cache/npm /root/.npm \ + && ln -s /pkg-cache/npm /home/myuser/.npm # Run everything after as non-privileged user. USER myuser @@ -84,6 +99,22 @@ ENV NODE_ENV=production # so we put back the old limit of 80kb, which seems to work just fine. ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000" +# Send every package-manager cache to a single, dedicated location instead of $HOME. +# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating +# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway +# cache data and can be wiped or mounted as tmpfs without touching installed dependencies. +ENV NPM_CONFIG_CACHE=/pkg-cache/npm \ + YARN_CACHE_FOLDER=/pkg-cache/yarn \ + YARN_GLOBAL_FOLDER=/pkg-cache/yarn \ + PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \ + PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache + +# Make pnpm and yarn use a flat, npm-style node_modules instead of their non-node_modules +# defaults (pnpm's symlinked store, yarn Berry's Plug'n'Play), so installed dependencies are +# plain copies that any tooling can resolve without symlinks or a PnP loader. +ENV PNPM_CONFIG_NODE_LINKER=hoisted \ + YARN_NODE_LINKER=node-modules + # Install default dependencies, print versions of everything RUN npm --quiet set progress=false \ && npm install --omit=dev --omit=optional --no-package-lock --prefer-online \ diff --git a/node-playwright/Dockerfile b/node-playwright/Dockerfile index bc65c758..c9932b22 100644 --- a/node-playwright/Dockerfile +++ b/node-playwright/Dockerfile @@ -83,13 +83,28 @@ RUN apt update \ # Globally disable the update-notifier. && npm config --global set update-notifier false \ \ + # Install the latest Corepack so Actors can opt into yarn or pnpm; `enable` drops the shims into the global bin. + && npm install -g corepack@latest \ + && corepack enable \ + \ + # Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any + # user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as. + && mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \ + && chmod -R 777 /pkg-cache \ + \ # Cleanup time && rm -rf /var/lib/apt/lists/* \ && rm -rf /src/*.deb \ && apt clean -y && apt autoremove -y \ && rm -rf /root/.npm \ # This is needed to remove an annoying error message when running headful. - && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix + && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \ + \ + # Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling + # that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working. + && rm -rf /root/.npm /home/myuser/.npm \ + && ln -s /pkg-cache/npm /root/.npm \ + && ln -s /pkg-cache/npm /home/myuser/.npm # Run everything after as non-privileged user. USER myuser @@ -107,6 +122,22 @@ ENV NODE_ENV=production # so we put back the old limit of 80kb, which seems to work just fine. ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000" +# Send every package-manager cache to a single, dedicated location instead of $HOME. +# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating +# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway +# cache data and can be wiped or mounted as tmpfs without touching installed dependencies. +ENV NPM_CONFIG_CACHE=/pkg-cache/npm \ + YARN_CACHE_FOLDER=/pkg-cache/yarn \ + YARN_GLOBAL_FOLDER=/pkg-cache/yarn \ + PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \ + PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache + +# Make pnpm and yarn use a flat, npm-style node_modules instead of their non-node_modules +# defaults (pnpm's symlinked store, yarn Berry's Plug'n'Play), so installed dependencies are +# plain copies that any tooling can resolve without symlinks or a PnP loader. +ENV PNPM_CONFIG_NODE_LINKER=hoisted \ + YARN_NODE_LINKER=node-modules + # Install default dependencies, print versions of everything RUN npm --quiet set progress=false \ && npm install --omit=dev --omit=optional --no-package-lock --prefer-online \ diff --git a/node-puppeteer-chrome/Dockerfile b/node-puppeteer-chrome/Dockerfile index 029d82c7..4df38202 100644 --- a/node-puppeteer-chrome/Dockerfile +++ b/node-puppeteer-chrome/Dockerfile @@ -90,13 +90,28 @@ RUN apt update \ \ # Globally disable the update-notifier. && npm config --global set update-notifier false \ + \ + # Install the latest Corepack so Actors can opt into yarn or pnpm; `enable` drops the shims into the global bin. + && npm install -g corepack@latest \ + && corepack enable \ + \ + # Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any + # user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as. + && mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \ + && chmod -R 777 /pkg-cache \ # Cleanup && rm -rf /var/lib/apt/lists/* \ && rm -rf /src/*.deb \ && apt clean -y && apt autoremove -y \ && rm -rf /root/.npm \ # This is needed to remove an annoying error message when running headful. - && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix + && mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix \ + \ + # Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling + # that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working. + && rm -rf /root/.npm /home/myuser/.npm \ + && ln -s /pkg-cache/npm /root/.npm \ + && ln -s /pkg-cache/npm /home/myuser/.npm # Run everything after as non-privileged user. USER myuser @@ -114,6 +129,22 @@ ENV NODE_ENV=production # so we put back the old limit of 80kb, which seems to work just fine. ENV NODE_OPTIONS="--max_old_space_size=30000 --max-http-header-size=80000" +# Send every package-manager cache to a single, dedicated location instead of $HOME. +# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating +# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway +# cache data and can be wiped or mounted as tmpfs without touching installed dependencies. +ENV NPM_CONFIG_CACHE=/pkg-cache/npm \ + YARN_CACHE_FOLDER=/pkg-cache/yarn \ + YARN_GLOBAL_FOLDER=/pkg-cache/yarn \ + PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \ + PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache + +# Make pnpm and yarn use a flat, npm-style node_modules instead of their non-node_modules +# defaults (pnpm's symlinked store, yarn Berry's Plug'n'Play), so installed dependencies are +# plain copies that any tooling can resolve without symlinks or a PnP loader. +ENV PNPM_CONFIG_NODE_LINKER=hoisted \ + YARN_NODE_LINKER=node-modules + # Install default dependencies, print versions of everything RUN npm --quiet set progress=false \ && npm install --omit=dev --omit=optional --no-package-lock --prefer-online \ diff --git a/node/Dockerfile b/node/Dockerfile index f1ec68be..40a34ccf 100644 --- a/node/Dockerfile +++ b/node/Dockerfile @@ -14,13 +14,44 @@ RUN npm config --global set update-notifier false \ && chown -R myuser:myuser /home/myuser \ && mkdir -p /usr/src/app \ && chown -R myuser:myuser /usr/src/app \ - && ln -s /usr/src/app /home/myuser + && ln -s /usr/src/app /home/myuser \ + \ + # Install the latest Corepack so Actors can opt into yarn or pnpm; `enable` drops the shims into the global bin. + && npm install -g corepack@latest \ + && corepack enable \ + \ + # Pre-create the shared package-manager cache dirs (see the *_CACHE_*/*_STORE_DIR env vars), world-writable so any + # user can populate them and `rm -rf` them at the end to reclaim space, regardless of which user the Actor runs as. + && mkdir -p /pkg-cache/npm /pkg-cache/yarn /pkg-cache/pnpm/store /pkg-cache/pnpm/cache \ + && chmod -R 777 /pkg-cache \ + \ + # Point the default per-user npm cache dirs (~/.npm) at the shared cache, so tooling + # that bypasses NPM_CONFIG_CACHE - and templates that `rm -r ~/.npm` - keep working. + && rm -rf /root/.npm /home/myuser/.npm \ + && ln -s /pkg-cache/npm /root/.npm \ + && ln -s /pkg-cache/npm /home/myuser/.npm WORKDIR /usr/src/app # Copy source code COPY --chown=myuser:myuser package.json main.js . +# Send every package-manager cache to a single, dedicated location instead of $HOME. +# npm, yarn, and pnpm have no real "disable the cache" switch (unlike pip), so isolating +# their caches under /pkg-cache is the practical equivalent: the tree holds only throwaway +# cache data and can be wiped or mounted as tmpfs without touching installed dependencies. +ENV NPM_CONFIG_CACHE=/pkg-cache/npm \ + YARN_CACHE_FOLDER=/pkg-cache/yarn \ + YARN_GLOBAL_FOLDER=/pkg-cache/yarn \ + PNPM_CONFIG_STORE_DIR=/pkg-cache/pnpm/store \ + PNPM_CONFIG_CACHE_DIR=/pkg-cache/pnpm/cache + +# Make pnpm and yarn use a flat, npm-style node_modules instead of their non-node_modules +# defaults (pnpm's symlinked store, yarn Berry's Plug'n'Play), so installed dependencies are +# plain copies that any tooling can resolve without symlinks or a PnP loader. +ENV PNPM_CONFIG_NODE_LINKER=hoisted \ + YARN_NODE_LINKER=node-modules + # Install default dependencies, print versions of everything RUN npm --quiet set progress=false \ && npm install --omit=dev --omit=optional --no-package-lock --prefer-online \