fix(docker): copy shared module AFTER npm install to prevent wipe
npm install was clearing the @iconsulting/shared folder that was copied before it. Moving the COPY command after npm install ensures the shared package remains in node_modules. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0c13140445
commit
6bb47dad85
|
|
@ -31,16 +31,16 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||||
COPY --from=builder /app/packages/services/conversation-service/dist ./dist
|
COPY --from=builder /app/packages/services/conversation-service/dist ./dist
|
||||||
COPY --from=builder /app/packages/services/conversation-service/package.json ./
|
COPY --from=builder /app/packages/services/conversation-service/package.json ./
|
||||||
|
|
||||||
# 复制 shared 包的构建产物
|
|
||||||
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
|
||||||
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
|
||||||
|
|
||||||
# 移除 workspace: 协议依赖并安装生产依赖
|
# 移除 workspace: 协议依赖并安装生产依赖
|
||||||
RUN apk add --no-cache jq && \
|
RUN apk add --no-cache jq && \
|
||||||
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
||||||
mv package.tmp.json package.json && \
|
mv package.tmp.json package.json && \
|
||||||
npm install --omit=dev --ignore-scripts
|
npm install --omit=dev --ignore-scripts
|
||||||
|
|
||||||
|
# 复制 shared 包的构建产物 (必须在 npm install 之后,否则会被清空)
|
||||||
|
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
||||||
|
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3004
|
ENV PORT=3004
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,6 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||||
COPY --from=builder /app/packages/services/evolution-service/dist ./dist
|
COPY --from=builder /app/packages/services/evolution-service/dist ./dist
|
||||||
COPY --from=builder /app/packages/services/evolution-service/package.json ./
|
COPY --from=builder /app/packages/services/evolution-service/package.json ./
|
||||||
|
|
||||||
# 复制 shared 包的构建产物
|
|
||||||
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
|
||||||
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
|
||||||
|
|
||||||
# 移除 workspace: 协议依赖并安装生产依赖
|
# 移除 workspace: 协议依赖并安装生产依赖
|
||||||
# bcrypt 需要原生编译,安装编译工具
|
# bcrypt 需要原生编译,安装编译工具
|
||||||
RUN apk add --no-cache jq python3 make g++ && \
|
RUN apk add --no-cache jq python3 make g++ && \
|
||||||
|
|
@ -43,6 +39,10 @@ RUN apk add --no-cache jq python3 make g++ && \
|
||||||
npm install --omit=dev && \
|
npm install --omit=dev && \
|
||||||
apk del python3 make g++
|
apk del python3 make g++
|
||||||
|
|
||||||
|
# 复制 shared 包的构建产物 (必须在 npm install 之后,否则会被清空)
|
||||||
|
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
||||||
|
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3005
|
ENV PORT=3005
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,6 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||||
COPY --from=builder /app/packages/services/file-service/dist ./dist
|
COPY --from=builder /app/packages/services/file-service/dist ./dist
|
||||||
COPY --from=builder /app/packages/services/file-service/package.json ./
|
COPY --from=builder /app/packages/services/file-service/package.json ./
|
||||||
|
|
||||||
# 复制 shared 包的构建产物 (因为依赖 workspace:*)
|
|
||||||
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
|
||||||
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
|
||||||
|
|
||||||
# 移除 workspace: 协议依赖并安装生产依赖
|
# 移除 workspace: 协议依赖并安装生产依赖
|
||||||
RUN apk add --no-cache jq python3 make g++ && \
|
RUN apk add --no-cache jq python3 make g++ && \
|
||||||
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
||||||
|
|
@ -56,6 +52,10 @@ RUN apk add --no-cache jq python3 make g++ && \
|
||||||
npm install --omit=dev && \
|
npm install --omit=dev && \
|
||||||
apk del python3 make g++
|
apk del python3 make g++
|
||||||
|
|
||||||
|
# 复制 shared 包的构建产物 (必须在 npm install 之后,否则会被清空)
|
||||||
|
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
||||||
|
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
||||||
|
|
||||||
# 设置环境变量
|
# 设置环境变量
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3006
|
ENV PORT=3006
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,16 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||||
COPY --from=builder /app/packages/services/knowledge-service/dist ./dist
|
COPY --from=builder /app/packages/services/knowledge-service/dist ./dist
|
||||||
COPY --from=builder /app/packages/services/knowledge-service/package.json ./
|
COPY --from=builder /app/packages/services/knowledge-service/package.json ./
|
||||||
|
|
||||||
# 复制 shared 包的构建产物
|
|
||||||
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
|
||||||
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
|
||||||
|
|
||||||
# 移除 workspace: 协议依赖并安装生产依赖
|
# 移除 workspace: 协议依赖并安装生产依赖
|
||||||
RUN apk add --no-cache jq && \
|
RUN apk add --no-cache jq && \
|
||||||
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
||||||
mv package.tmp.json package.json && \
|
mv package.tmp.json package.json && \
|
||||||
npm install --omit=dev --ignore-scripts
|
npm install --omit=dev --ignore-scripts
|
||||||
|
|
||||||
|
# 复制 shared 包的构建产物 (必须在 npm install 之后,否则会被清空)
|
||||||
|
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
||||||
|
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3003
|
ENV PORT=3003
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,16 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||||
COPY --from=builder /app/packages/services/payment-service/dist ./dist
|
COPY --from=builder /app/packages/services/payment-service/dist ./dist
|
||||||
COPY --from=builder /app/packages/services/payment-service/package.json ./
|
COPY --from=builder /app/packages/services/payment-service/package.json ./
|
||||||
|
|
||||||
# 复制 shared 包的构建产物
|
|
||||||
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
|
||||||
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
|
||||||
|
|
||||||
# 移除 workspace: 协议依赖并安装生产依赖
|
# 移除 workspace: 协议依赖并安装生产依赖
|
||||||
RUN apk add --no-cache jq && \
|
RUN apk add --no-cache jq && \
|
||||||
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
jq 'del(.dependencies["@iconsulting/shared"])' package.json > package.tmp.json && \
|
||||||
mv package.tmp.json package.json && \
|
mv package.tmp.json package.json && \
|
||||||
npm install --omit=dev --ignore-scripts
|
npm install --omit=dev --ignore-scripts
|
||||||
|
|
||||||
|
# 复制 shared 包的构建产物 (必须在 npm install 之后,否则会被清空)
|
||||||
|
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
||||||
|
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3002
|
ENV PORT=3002
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,6 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||||
COPY --from=builder /app/packages/services/user-service/dist ./dist
|
COPY --from=builder /app/packages/services/user-service/dist ./dist
|
||||||
COPY --from=builder /app/packages/services/user-service/package.json ./
|
COPY --from=builder /app/packages/services/user-service/package.json ./
|
||||||
|
|
||||||
# 复制 shared 包的构建产物 (因为依赖 workspace:*)
|
|
||||||
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
|
||||||
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
|
||||||
|
|
||||||
# 移除 workspace: 协议依赖并安装生产依赖
|
# 移除 workspace: 协议依赖并安装生产依赖
|
||||||
# bcrypt 需要原生编译,安装编译工具
|
# bcrypt 需要原生编译,安装编译工具
|
||||||
RUN apk add --no-cache jq python3 make g++ && \
|
RUN apk add --no-cache jq python3 make g++ && \
|
||||||
|
|
@ -54,6 +50,10 @@ RUN apk add --no-cache jq python3 make g++ && \
|
||||||
npm install --omit=dev && \
|
npm install --omit=dev && \
|
||||||
apk del python3 make g++
|
apk del python3 make g++
|
||||||
|
|
||||||
|
# 复制 shared 包的构建产物 (必须在 npm install 之后,否则会被清空)
|
||||||
|
COPY --from=builder /app/packages/shared/dist ./node_modules/@iconsulting/shared/dist
|
||||||
|
COPY --from=builder /app/packages/shared/package.json ./node_modules/@iconsulting/shared/
|
||||||
|
|
||||||
# 设置环境变量
|
# 设置环境变量
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3001
|
ENV PORT=3001
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue