fix(deploy): fallback to npm install when lockfile missing in Dockerfiles

This commit is contained in:
2025-08-25 09:31:14 +08:00
parent cd89cc7619
commit 10938766f4
2 changed files with 4 additions and 2 deletions

View File

@@ -1,7 +1,8 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY backend/package*.json ./
RUN npm ci --production
# Use npm ci if a lockfile exists, otherwise fall back to npm install
RUN sh -c 'if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then npm ci --production; else npm install --production; fi'
COPY backend/ ./
RUN npm run build --prefix backend

View File

@@ -1,7 +1,8 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY frontend/package*.json ./
RUN npm ci
# Use npm ci when lockfile exists, fallback to npm install
RUN sh -c 'if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then npm ci; else npm install; fi'
COPY frontend/ ./
RUN npm run build --prefix frontend