I don't like how Corepack downloads aren't cached #53818
Replies: 1 comment
-
I figured out how to avoid the repeated download. Install pnpm at the top of the dockerfile, thus using docker layer caching. FROM node:20.15 as base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
WORKDIR /usr/src/app
## important line as follows. Don't just enable corepack-- also prepare and activate pnpm!
RUN corepack enable && corepack prepare [email protected] --activate This way, the download only happens on the first build. Subsequent builds will use the docker image cache and skip downloading again. As for the fetching of Node.js, that's pnpm doing that, because I have use-node-version specified in .npmrc. Even though I'm already using 20.15 as seen in the docker image tag, pnpm doesn't care and downloads the specified version unconditionally. The workaround is to not use With these changes, my |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Corepack is slowing me down. I am in a limited bandwidth environment and working on dockerizing my monorepo with 4 node packages. The package build process is painfully slow because Corepack has to re-download pnpm every time I build.
On any given package, one of the slowest steps happens during
pnpm install
. During this step, Corepack downloads pnpm from the internet. Why? I don't want it to download pnpm every single build, but that's what it does. Can't it cache pnpm on my local machine? I don't see a way to do that.I don't want corepack to download anything during the docker build. I don't want pnpm to download anything either. Here is my pnpm install incantation.
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --offline
Even though I specify
--offline
, corepack downloads pnpm and fetches node.It takes 52.3s to complete this step. Given that in development I have to build the image hundreds of times a day, this is a lot. I wish I could cache pnpm and nodejs inside the dockerfile using Corepack, but I don't see any way to do that.
Beta Was this translation helpful? Give feedback.
All reactions