Skip to content

Commit c0d0bff

Browse files
root: bind-mount .npmrc into Dockerfile npm ci stages (#22462)
* root: bind-mount .npmrc into Dockerfile npm ci stages `npm` walks up from cwd looking for `.npmrc`. The two Dockerfiles that run `npm ci` (`lifecycle/container/Dockerfile` for the web build and `website/Dockerfile` for the docs build) bind-mount package.json / package-lock.json into the build context, but not `.npmrc`. As a result the project-level settings — most importantly `ignore-scripts=true` — are not honored inside the container, so a hypothetical malicious package's preinstall/postinstall hook would execute during the image build. Adding `--mount=type=bind,target=/work/.npmrc,src=./.npmrc` to each `npm ci` step closes that gap. The mount is read-only and only present for the install step, so it adds no layer weight. Co-authored-by: Agent <279763771+playpen-agent@users.noreply.github.com> * Update bindmount. --------- Co-authored-by: Agent <279763771+playpen-agent@users.noreply.github.com>
1 parent 85d645d commit c0d0bff

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

lifecycle/container/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ WORKDIR /work/web
2424
COPY ./packages /work/packages
2525
COPY ./web/packages /work/web/packages
2626

27-
RUN --mount=type=bind,target=/work/web/package.json,src=./web/package.json \
27+
RUN --mount=type=bind,target=/work/.npmrc,src=./.npmrc \
28+
--mount=type=bind,target=/work/web/package.json,src=./web/package.json \
2829
--mount=type=bind,target=/work/web/package-lock.json,src=./web/package-lock.json \
2930
--mount=type=bind,target=/work/web/packages/sfe/package.json,src=./web/packages/sfe/package.json \
3031
--mount=type=bind,target=/work/web/scripts,src=./web/scripts \

lifecycle/container/proxy.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ RUN --mount=type=bind,target=/static/package.json,src=./package.json \
2121

2222
COPY package.json /
2323

24-
RUN --mount=type=bind,target=/static/package.json,src=./web/package.json \
24+
RUN --mount=type=bind,target=/static/.npmrc,src=./.npmrc \
25+
--mount=type=bind,target=/static/package.json,src=./web/package.json \
2526
--mount=type=bind,target=/static/package-lock.json,src=./web/package-lock.json \
2627
--mount=type=bind,target=/static/scripts,src=./web/scripts \
2728
--mount=type=cache,target=/root/.npm \

website/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ RUN --mount=type=bind,target=/work/package.json,src=./package.json \
1717
node ./scripts/node/setup-corepack.mjs --force && \
1818
node ./scripts/node/lint-runtime.mjs ./website
1919

20-
RUN --mount=type=bind,target=/work/package.json,src=./package.json \
20+
RUN --mount=type=bind,target=/work/.npmrc,src=./.npmrc \
21+
--mount=type=bind,target=/work/package.json,src=./package.json \
2122
--mount=type=bind,target=/work/package-lock.json,src=./package-lock.json \
2223
--mount=type=bind,target=/work/scripts/node/,src=./scripts/node/ \
2324
--mount=type=bind,target=/work/packages/logger-js/,src=./packages/logger-js/ \

0 commit comments

Comments
 (0)