Files
Edu/infra/apollo-router/router.yaml
SpecialX 682f323bad chore(infra): docker dev-apps stack + apollo-router v1.45 compat
- 新增 docker-compose.dev-apps.yml:7 个应用服务容器化
  (iam/classes/core-edu/content/msg/push-gateway/api-gateway)
  + apollo-router override
- 新增 apollo-router dev-apps-entrypoint.sh / dev-apps-supergraph.yaml
  仅等待 5 个子图(iam/core-edu/content/msg/config-service)
  避免等待未启动的 ai/data-ana
- router.yaml:移除 v1.45 不兼容键
  (require_manifest/manifest_path/max_cost/max_batch_size)
  移除 ELv2 受限特性(persisted_queries/limits.max_depth)
  自托管无 GraphOS license
- docker-compose.yml:config-service 添加 NODE_ENV=production
  修复 pino-pretty devDep 误用
  apollo-router 添加 APOLLO_PERSISTED_QUERIES env
- services/{classes,core-edu,content,config-service}/Dockerfile
  重写为 repo 根 context + shared-ts/shared-proto 工作区依赖
  + --ignore-scripts
  修复 ERR_PNPM_WORKSPACE_PKG_NOT_FOUND 与 ERR_PNPM_IGNORED_BUILDS
- api-gateway healthcheck:wget --spider 改为 wget -O /dev/null
  修复 busybox 对 200+body 误报 exit 8
2026-07-22 11:35:02 +08:00

99 lines
3.0 KiB
YAML
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.
# Apollo Router 配置v2.1 M2 + M3 安全加固)
#
# Router 作为唯一的外部 GraphQL 入口,替代 3 个 BFF 的手动聚合。
# 前端 → RouterGraphQL→ 各子图(/graphql
# 内部调用(后端 → 后端)仍走 gRPCADR-037
#
# 端口3000GraphQL/ 8088健康检查
# 镜像ghcr.io/apollographql/router:v1.45.0
#
# v2.1 M3 安全加固:
# - APQ + manifest 校验(生产拒绝未知 hash
# - 深度/复杂度限制
# - 生产关闭 introspection通过环境变量控制
# - 生产仅允许 POSTcsrf.enabled 阻止 GET 查询)
supergraph:
listen: 0.0.0.0:3000
path: /graphql
# 生产关闭 introspectionAPOLLO_ROUTER_INTROSPECTION=false
# 开发默认 true 便于调试(由 docker-compose environment 注入)
introspection: ${env.APOLLO_ROUTER_INTROSPECTION}
# 持久化查询v2.1 M3 安全加固)
# 关联portal-shell spec §4.3
# 注意Apollo Router v1.45 的 persisted_queries 是 ELv2 受限特性,
# 需连接 GraphOSAPOLLO_KEY + APOLLO_GRAPH_REF才能启用。
# 自托管开发态禁用此特性;生产环境如需启用,需配置 GraphOS license。
# persisted_queries:
# enabled: false
# 查询限制v2.1 M3 安全加固)
# 注意Apollo Router v1.45 的 limits.max_depth 是 ELv2 受限特性,
# 需连接 GraphOS 才能启用。自托管开发态禁用;
# 生产环境如需深度限制,可使用 rhai script 或 custom plugin 替代。
# limits:
# max_depth: 10
# Sandbox 模式支持开发和调试v1.45 中 sandbox 已合并到 homepage
homepage:
enabled: true
# CORS允许前端 portal 访问
cors:
origins:
- "http://localhost:4000"
- "http://localhost:4001"
- "http://localhost:4002"
- "http://localhost:4003"
- "http://localhost:4010"
- "http://teacher-portal:4000"
- "http://student-portal:4001"
- "http://parent-portal:4002"
- "http://admin-portal:4003"
- "http://portal-shell:4010"
methods:
- GET
- POST
- OPTIONS
allow_credentials: true
allow_headers:
- Authorization
- Content-Type
- X-Request-Id
- X-Expected-Version
- If-Match
# 向所有子图注入 Router-Authorization HeaderADR-036
# 子图的 RouterAuthGuard 校验此 Header拒绝非 Router 的直接 GraphQL 请求
# 同时透传用户身份头x-user-id / x-user-role与 Authorization 到子图,
# 供 iam/core-edu/msg 等子图做用户级鉴权M8portal-shell 查询走 Router
headers:
all:
request:
- insert:
name: "router-authorization"
value: "dev-router-secret"
- propagate:
named: "Authorization"
- propagate:
named: "x-user-id"
- propagate:
named: "x-user-role"
- propagate:
named: "X-Request-Id"
# 健康检查
health_check:
listen: 0.0.0.0:8088
# 日志v1.45 使用 telemetry.exporters.logging
telemetry:
exporters:
logging:
stdout:
format: json
instrumentation:
spans:
mode: spec_compliant