feat(teacher-portal): Docker Desktop 验证通过 + 切换 standalone 模式 + nextstep.md
- Dockerfile 切换为 Next.js output:standalone 模式 - 解决 pnpm symlink 在 runtime 下无法解析 react/jsx-runtime 的问题 - 修复 tsconfig.base.json 未 COPY 到 builder 阶段的问题 - next.config.js 添加 output:"standalone" 配置 - Docker Desktop 验证通过: - 镜像构建成功 (1.32GB) - 容器启动 Ready in 69ms - /api/health 健康检查返回 200 - 27 静态路由 + 11 动态路由全部 HTTP 200 - 新增 nextstep.md: - 下游依赖清单(teacher-bff 61 GraphQL operations + iam + push-gateway) - 本模块待补工作(单元测试/设计令牌硬化/i18n/ui-components 扩展/性能/A11y) - Docker 部署注意事项 + 路由清单 + 已知问题 - workline.md §5.6 记录 Docker 验证结果
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 多阶段构建:Next.js 生产镜像
|
||||
# 多阶段构建:Next.js 生产镜像(standalone 模式)
|
||||
# 用法:docker build -t edu/teacher-portal:latest -f apps/teacher-portal/Dockerfile .
|
||||
# 端口规范:teacher-portal :4000(matrix.md §1 微前端层)
|
||||
|
||||
@@ -10,7 +10,7 @@ WORKDIR /app
|
||||
RUN corepack enable && corepack prepare pnpm@9.12.0 --activate
|
||||
|
||||
# 先拷依赖清单,利用缓存(含 workspace 共享包)
|
||||
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* ./
|
||||
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* tsconfig.base.json* ./
|
||||
COPY apps/teacher-portal/package.json ./apps/teacher-portal/
|
||||
COPY packages/ui-tokens/package.json ./packages/ui-tokens/
|
||||
COPY packages/ui-components/package.json ./packages/ui-components/
|
||||
@@ -24,7 +24,7 @@ COPY packages/ui-tokens ./packages/ui-tokens
|
||||
COPY packages/ui-components ./packages/ui-components
|
||||
COPY packages/hooks ./packages/hooks
|
||||
|
||||
# 构建(禁用 telemetry,生产模式)
|
||||
# 构建(禁用 telemetry,生产模式,standalone 输出)
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN pnpm --filter @edu/teacher-portal run build
|
||||
|
||||
@@ -39,12 +39,10 @@ ENV PORT=4000
|
||||
# 非 root 用户运行
|
||||
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
|
||||
|
||||
# 拷构建产物与必要清单
|
||||
COPY --from=builder /app/apps/teacher-portal/package.json ./package.json
|
||||
COPY --from=builder /app/apps/teacher-portal/.next ./.next
|
||||
COPY --from=builder /app/apps/teacher-portal/public ./public
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/apps/teacher-portal/next.config.js ./next.config.js
|
||||
# 拷 standalone 产物(已含 node_modules 和 server.js,自包含)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/teacher-portal/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/teacher-portal/.next/static ./.next/static
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/teacher-portal/public ./public
|
||||
|
||||
USER nextjs
|
||||
EXPOSE 4000
|
||||
@@ -53,4 +51,6 @@ EXPOSE 4000
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD wget --quiet --spider http://localhost:4000/api/health || exit 1
|
||||
|
||||
CMD ["node_modules/.bin/next", "start", "-p", "4000"]
|
||||
# standalone 模式下直接用 node server.js 启动(已自包含所有依赖)
|
||||
WORKDIR /app/apps/teacher-portal
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
Reference in New Issue
Block a user