Files
Edu/apps/teacher-portal/Dockerfile
SpecialX 81a539b9ab
Some checks failed
CI / quality-ts (push) Failing after 6s
CI / quality-go (push) Failing after 25s
CI / quality-proto (push) Failing after 6s
CI / deploy (push) Has been skipped
chore(deps): 统一依赖管理 - pnpm 11 + node:22 + golang:1.25 + python:3.12 + shared-* 集中化
- Node.js 统一到 node:22-alpine,Go 统一到 golang:1.25-alpine,Python 统一到 python:3.12-slim

- pnpm 升级到 11.13.0(corepack),新增 allowBuilds 白名单解决 ERR_PNPM_IGNORED_BUILDS

- 新增 packages/shared-py 集中 Python 共享依赖,shared-ts 补充 graphql-yoga/prom-client

- api-gateway 修复 go.mod 的 shared-go 依赖 + Dockerfile 改用 repo 根作 context

- Python 服务(data-ana/ai)Dockerfile 改用 repo 根作 context + 声明 uv workspace sources

- 16 个服务的 Dockerfile + CI + docker-compose.tools.yml 全部对齐版本矩阵

- known-issues.md 沉淀 9 条 pnpm 11 / uv workspace / Go shared-go 迁移经验

- 验证:4 服务完全成功(api-gateway /healthz 200),其余 install 成功(build 失败为预存 TS 错误)
2026-07-14 12:04:49 +08:00

57 lines
2.2 KiB
Docker
Raw 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.
# 多阶段构建Next.js 生产镜像standalone 模式)
# 用法docker build -t edu/teacher-portal:latest -f apps/teacher-portal/Dockerfile .
# 端口规范teacher-portal :4000matrix.md §1 微前端层)
# ============ Builder ============
FROM node:22-alpine AS builder
WORKDIR /app
# 启用 pnpm
RUN corepack enable && corepack prepare pnpm@11.13.0 --activate
# 先拷依赖清单,利用缓存(含 workspace 共享包)
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/
COPY packages/hooks/package.json ./packages/hooks/
# 安装依赖(含 devDependencies构建需要
RUN pnpm install --filter @edu/teacher-portal... --frozen-lockfile || pnpm install --filter @edu/teacher-portal...
# 拷源码
COPY apps/teacher-portal ./apps/teacher-portal
COPY packages/ui-tokens ./packages/ui-tokens
COPY packages/ui-components ./packages/ui-components
COPY packages/hooks ./packages/hooks
# 构建(禁用 telemetry生产模式standalone 输出)
ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm --filter @edu/teacher-portal run build
# ============ Runtime ============
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=4000
# 非 root 用户运行
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
# 拷 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
# 健康检查(/api/health liveness 端点)
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD wget --quiet --spider http://localhost:4000/api/health || exit 1
# standalone 模式下直接用 node server.js 启动(已自包含所有依赖)
WORKDIR /app/apps/teacher-portal
CMD ["node", "server.js"]