Skip to content

Commit c237e30

Browse files
refactor: Update Dockerfile to conditionally install npm dependencies using npm ci or npm install based on package-lock.json availability.
1 parent 6e28213 commit c237e30

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ FROM node:20-alpine AS build
33
WORKDIR /app
44

55
# Install dependencies with cache mount for npm cache
6-
COPY package.json package-lock.json ./
6+
# Some branches intentionally do not track package-lock.json.
7+
# Copy whichever npm manifest files exist and install accordingly.
8+
COPY package*.json ./
79
RUN npm config set fetch-retries 10 \
810
&& npm config set fetch-retry-mintimeout 30000 \
911
&& npm config set fetch-retry-maxtimeout 300000
1012

1113
RUN --mount=type=cache,target=/root/.npm \
12-
npm ci --legacy-peer-deps --no-audit --no-fund --registry=https://registry.npmjs.org/
14+
if [ -f package-lock.json ]; then \
15+
npm ci --legacy-peer-deps --no-audit --no-fund --registry=https://registry.npmjs.org/; \
16+
else \
17+
npm install --legacy-peer-deps --no-audit --no-fund --registry=https://registry.npmjs.org/; \
18+
fi
1319

1420

1521
# Copy source code

0 commit comments

Comments
 (0)