Files
fquiz/memory/2026-06-09.md
T
2026-06-09 10:29:21 +08:00

62 lines
4.3 KiB
Markdown
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.
## Work Log - 修复 Buildx 安装阶段访问 Docker Hub 超时(2026-06-09
- 背景:
- GitHub Actions run `27150975287``build-and-push` job 的 `安装 Buildx` 步骤失败,后续镜像构建与部署全部被跳过。
- check-run annotation 给出的精确错误为:
- `Head "https://registry-1.docker.io/v2/moby/buildkit/manifests/buildx-stable-1" ... Client.Timeout exceeded while awaiting headers`
- 根因不是仓库镜像构建脚本本身,而是 `docker/setup-buildx-action` 默认 `docker-container` 驱动在启动 BuildKit builder 时,需要先从 Docker Hub 拉 `moby/buildkit:buildx-stable-1`,受外网访问抖动影响直接超时。
- 本次处理:
- `.github/workflows/main.yml`
- `actions/checkout` 升级到 `v6`
- `docker/setup-buildx-action` 升级到 `v4`,并显式指定:
- `driver-opts: image=docker.m.daocloud.io/moby/buildkit:buildx-stable-1`
- 避免 Buildx 初始化再访问 Docker Hub 拉默认 BuildKit 镜像。
- `docker/login-action` 升级到 `v4`
- `docker/build-push-action` 升级到 `v7`
- 兼带收益:
- 消除了该次 run 中出现的 `Node.js 20 actions are deprecated` 预警里的旧版 `checkout/setup-buildx`
- 验证:
- 基线:
- GitHub Actions run `27150975287` 失败,且失败点固定在 `安装 Buildx`
- check-run annotation 可复核到 Docker Hub `moby/buildkit` 拉取超时。
- 修改后:
- `python3` 解析 `.github/workflows/main.yml` 通过。
- `actionlint` 校验变更前/变更后 workflow 均可解析,变更未引入 YAML / Actions 语法问题。
- `git diff --check -- .github/workflows/main.yml` 通过。
- 当前环境限制:
- 无法直接在本地实际执行 GitHub hosted runner 上的 `setup-buildx` 拉起流程,真实恢复效果需要依赖下一次 Actions 运行确认。
- 风险与关注点:
- 本次修复只绕开 BuildKit builder 镜像对 Docker Hub 的依赖;后续若 `Dockerfile` 里的基础镜像或 `docker build --pull` 仍指向不稳定上游,构建阶段仍可能出现其他网络相关失败。
## Work Log - 修复线路管理走向图在 `/fl` 子路径下无法渲染(2026-06-09
- 背景:
- Issue `FL-60` 反馈“线路管理中走向图渲染不出来”。
- 仓库部署默认启用 `NEXT_PUBLIC_APP_BASE_PATH=/fl`,但多个 Cesium 组件初始化时仍把 `window.CESIUM_BASE_URL` 硬编码为 `"/cesium"`
- 这会导致页面在 `/fl/admin/power-lines` 等子路径下请求错误的静态资源地址,最终触发 Cesium Viewer 初始化失败。
- 本次处理:
- `web/src/components/power-line-cesium-map.tsx`
- 将走向图 Cesium 静态资源根路径改为 `withBasePath("/cesium")`,修复线路管理走向图在 `/fl` 部署下的资源寻址。
- `web/src/components/elevation-preview-cesium-map.tsx`
- 同步改为 `withBasePath("/cesium")`,避免高程预览图在相同部署口径下继续空白。
- `web/src/components/lightning-distribution-map.tsx`
- 同步改为 `withBasePath("/cesium")`,保持雷电分布图与项目子路径部署口径一致。
- 顺手补齐 `Viewer` / `CesiumNamespace` / `Cartesian3[]` 显式类型,消除本地 lint 暴露的 `no-explicit-any` 问题。
- 验证:
- 基线:
- 代码检查确认 `power-line-cesium-map.tsx``elevation-preview-cesium-map.tsx``lightning-distribution-map.tsx` 都存在 `window.CESIUM_BASE_URL = "/cesium"` 硬编码。
- 部署配置检查确认 `deploy/pro-deploy/.env` 与 compose / Dockerfile 默认均为 `NEXT_PUBLIC_APP_BASE_PATH=/fl`
- 初次本地 lint 尝试因未安装前端依赖失败;补充执行 `NPM_CONFIG_CACHE=/tmp/npm-cache npm ci` 后继续验证。
- 修改后:
- `NPM_CONFIG_CACHE=/tmp/npm-cache npm --workspace web exec eslint src/components/power-line-cesium-map.tsx src/components/elevation-preview-cesium-map.tsx src/components/lightning-distribution-map.tsx src/app/admin/power-lines/page.tsx --max-warnings=0` -> 通过。
- `NEXT_PUBLIC_APP_BASE_PATH=/fl NPM_CONFIG_CACHE=/tmp/npm-cache npm run build:web` -> 通过。
- 风险与关注点:
- 本次修复聚焦前端静态资源路径,不涉及后端接口、数据库或权限逻辑。
- 若后续新增 Cesium 页面,必须继续复用 `withBasePath("/cesium")`,不能再硬编码根路径。