Files
Edu/services/parent-bff/Dockerfile

41 lines
1.5 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Build stage
# 构建上下文必须为 repo root以访问 packages/shared-proto + packages/shared-ts
FROM node:22-alpine AS builder
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@11.13.0 --activate
# 先复制所有源码(含 tsconfig.json / nest-cli.json / proto / graphql schema
COPY packages/shared-proto ./packages/shared-proto
COPY packages/shared-ts ./packages/shared-ts
COPY services/parent-bff ./services/parent-bff
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json tsconfig.base.json ./
# 安装依赖(含 devDependencies 用于构建,--ignore-scripts 跳过 husky
WORKDIR /app/services/parent-bff
RUN pnpm install --no-frozen-lockfile --ignore-scripts
# 构建
RUN pnpm build
# Runtime stage
FROM node:22-alpine
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@11.13.0 --activate
# 复制 parent-bff package.json独立安装生产依赖
COPY services/parent-bff/package.json ./services/parent-bff/package.json
WORKDIR /app/services/parent-bff
RUN pnpm install --prod --no-frozen-lockfile --ignore-workspace --ignore-scripts
# 复制 shared-proto + shared-ts运行时 proto/schema 加载需要)
WORKDIR /app
COPY packages/shared-proto ./packages/shared-proto
COPY packages/shared-ts ./packages/shared-ts
# 复制构建产物(保持 services/parent-bff/dist 结构)
COPY --from=builder /app/services/parent-bff/dist ./services/parent-bff/dist
WORKDIR /app/services/parent-bff
EXPOSE 3010
CMD ["node", "dist/main.js"]