fix: admin-service/telemetry-service Dockerfile 改为多阶段构建

修复缺少 builder 阶段导致 COPY dist/ 找不到目录的问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-19 17:29:56 -08:00
parent bc0d1e0876
commit c11d009ae7
2 changed files with 26 additions and 8 deletions

View File

@ -1,7 +1,16 @@
FROM node:20-alpine
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist/ ./dist/
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
RUN apk add --no-cache dumb-init
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
USER node
EXPOSE 3012
CMD ["node", "dist/main"]
CMD ["dumb-init", "node", "dist/main"]

View File

@ -1,7 +1,16 @@
FROM node:20-alpine
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist/ ./dist/
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
RUN apk add --no-cache dumb-init
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
USER node
EXPOSE 3011
CMD ["node", "dist/main"]
CMD ["dumb-init", "node", "dist/main"]