From 79689c5f9507c306dff0ce47ffee89ddbde2eed9 Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 11 Feb 2026 01:39:14 -0800 Subject: [PATCH] fix: Make Dockerfile tolerant of missing package-lock.json The initial project has no node_modules or package-lock.json yet. Use wildcard COPY for lock file and fallback to `npm install` when lock file doesn't exist. Once lock file is generated and committed, it will automatically use the faster `npm ci`. Co-Authored-By: Claude Opus 4.6 --- frontend/admin-web/Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/admin-web/Dockerfile b/frontend/admin-web/Dockerfile index f7220c2..5bd6071 100644 --- a/frontend/admin-web/Dockerfile +++ b/frontend/admin-web/Dockerfile @@ -3,11 +3,12 @@ FROM node:20-alpine AS deps RUN apk add --no-cache libc6-compat WORKDIR /app -# 复制依赖文件 -COPY package.json package-lock.json ./ +# 复制依赖文件 (lock文件可选,首次构建会自动生成) +COPY package.json ./ +COPY package-lock.json* ./ -# 安装依赖 -RUN npm ci --only=production=false +# 安装依赖 (有lock文件用ci,没有则用install) +RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi # 阶段2: 构建 FROM node:20-alpine AS builder