Skip to content

Commit c1f71e1

Browse files
authored
Update Docker recipe: add note to explain why we have npm ci command duplicated (#6)
1 parent 87505a8 commit c1f71e1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

recipes/docker-image-guide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ RUN --mount=type=secret,id=npmrc_secret,target=/usr/src/app/.npmrc,required npm
6262
# https://cheatsheetseries.owasp.org/cheatsheets/NodeJS_Docker_Cheat_Sheet.html#2-install-only-production-dependencies-in-the-nodejs-docker-image
6363
# when NODE_ENV is set to production, npm ci automatically omits dev dependencies
6464
# https://docs.npmjs.com/cli/v10/commands/npm-ci#omit
65+
# NOTE: if we don't have secrets, this is how we install npm packages, however if we
66+
# do have npmrc secret, we skip this step and proceed to the next.
6567
RUN npm ci --omit=dev
68+
# we can mount .npmrc secret file without leaving the secrets in the final built image
69+
# refer to docs https://docs.docker.com/build/building/secrets/
70+
RUN --mount=type=secret,id=npmrc_secret,target=/usr/src/app/.npmrc,required npm ci --omit=dev
6671

6772
FROM base AS configure
6873
WORKDIR /usr/src/app

0 commit comments

Comments
 (0)