Skip to content

Commit 9baaee2

Browse files
committed
build: add Docker support for missing lockfile
Allow the Docker build to fall back to `npm install` if `package-lock.json` is missing and add a comprehensive `.dockerignore` file to optimize image build contexts.
1 parent 87a53ad commit 9baaee2

3 files changed

Lines changed: 999 additions & 4 deletions

File tree

‎.dockerignore‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
node_modules
2+
dist
3+
data
4+
*.log
5+
.git
6+
.github
7+
*.local
8+
.env
9+
current_creds.json
10+
audit_log.json
11+
instances_meta.json
12+
proxy_config.json
13+
routing_profiles.json
14+
rotation_config.json
15+
rotation_history.json
16+
dashboard_auth.json
17+
extension_build_config.json

‎Dockerfile‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ WORKDIR /app
1111
RUN apk add --no-cache python3 make g++ git
1212

1313
# Copy dependency manifests (package-lock.json is committed - npm ci works)
14-
COPY package.json package-lock.json ./
14+
COPY package.json package-lock.json* ./
1515

1616
# Install all dependencies (including devDependencies for build)
17-
RUN npm ci
17+
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
1818

1919
# Copy application source code
2020
COPY . .
@@ -42,8 +42,8 @@ RUN addgroup -g 1001 -S pecgroup && \
4242
adduser -u 1001 -S pecuser -G pecgroup
4343

4444
# Runtime dependencies only: the bundle (dist/server.cjs) externalizes packages
45-
COPY --from=builder --chown=pecuser:pecgroup /app/package.json /app/package-lock.json ./
46-
RUN npm ci --omit=dev && npm cache clean --force
45+
COPY --from=builder --chown=pecuser:pecgroup /app/package.json /app/package-lock.json* ./
46+
RUN if [ -f package-lock.json ]; then npm ci --omit=dev; else npm install --omit=dev; fi && npm cache clean --force
4747

4848
# Built bundle only - server.ts/src are not needed at runtime
4949
COPY --from=builder --chown=pecuser:pecgroup /app/dist ./dist

0 commit comments

Comments
 (0)