feat(parent-portal): docker 构建修复 + 禁用 mock + 记录下游待办

Dockerfile 改用 standalone 模式

next.config.js 添加 output standalone

修复 cssnano-simple 构建失败:globals.css 注释含 */ 被误解析

tailwind.config.js 覆盖 boxShadow 为 rgba 格式 + 禁用 ringWidth

组件修复:替换 / 语法为 inline style 或自定义类

otel.ts 添加 webpackIgnore 跳过 optionalDependencies 静态分析

.env.example 默认禁用 mock

新增 .dockerignore 和 docs/nextstep.md

删除 postcss.config.js

验证:Docker 镜像构建成功,容器 healthy,typecheck + lint 零错误
This commit is contained in:
SpecialX
2026-07-13 17:21:39 +08:00
parent 8b729a710f
commit 96a936e154
14 changed files with 453 additions and 55 deletions

View File

@@ -1,4 +1,4 @@
# 多阶段构建Next.js 生产镜像parent-portal MF Remote
# 多阶段构建Next.js 生产镜像parent-portalstandalone 模式
# 用法docker build -t edu/parent-portal:latest -f apps/parent-portal/Dockerfile .
# 依据02-architecture-design.md §16 部署、G1 裁决(首次即多阶段)
# 端口40024 端 portal 强制 4000-4003
@@ -12,6 +12,7 @@ RUN corepack enable && corepack prepare pnpm@9.12.0 --activate
# 先拷依赖清单,利用缓存
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* ./
COPY tsconfig.base.json ./tsconfig.base.json
COPY apps/parent-portal/package.json ./apps/parent-portal/
# 安装依赖(含 devDependencies构建需要
RUN pnpm install --filter @edu/parent-portal... --frozen-lockfile || pnpm install --filter @edu/parent-portal...
@@ -19,9 +20,8 @@ RUN pnpm install --filter @edu/parent-portal... --frozen-lockfile || pnpm instal
# 拷源码
COPY apps/parent-portal ./apps/parent-portal
# 构建(禁用 telemetry生产模式
# 构建(禁用 telemetry生产模式standalone 输出
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
RUN pnpm --filter @edu/parent-portal run build
# ============ Runtime ============
@@ -31,22 +31,25 @@ WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=4002
# standalone server.js 默认绑定 HOSTNAMEDocker 中为容器 ID导致 localhost 不可达
# 强制绑定 0.0.0.0 让健康检查 wget localhost 能连通
ENV HOSTNAME=0.0.0.0
# 非 root 用户运行
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
# 拷构建产物与必要清单
COPY --from=builder /app/apps/parent-portal/package.json ./package.json
COPY --from=builder /app/apps/parent-portal/.next ./.next
COPY --from=builder /app/apps/parent-portal/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/apps/parent-portal/next.config.js ./next.config.js
# 拷 standalone 产物(已含 node_modules 和 server.js自包含
COPY --from=builder --chown=nextjs:nodejs /app/apps/parent-portal/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/parent-portal/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/apps/parent-portal/public ./public
USER nextjs
EXPOSE 4002
# 健康检查
# 健康检查(使用 127.0.0.1 而非 localhost避免容器内 hosts 解析问题)
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD wget --quiet --spider http://localhost:4002/api/health || exit 1
CMD wget --quiet --spider http://127.0.0.1:4002/api/health || exit 1
CMD ["node_modules/.bin/next", "start", "-p", "4002"]
# standalone 模式下直接用 node server.js 启动(已自包含所有依赖)
WORKDIR /app/apps/parent-portal
CMD ["node", "server.js"]