修改打包脚本

This commit is contained in:
2026-08-18 23:45:32 +08:00
parent a76c8d2613
commit 58d1ddc264
2 changed files with 95 additions and 1 deletions

View File

@@ -0,0 +1,94 @@
# Task: Diagnose Next.js production image build failure
## Identity
- Task ID: 20260818-next-build-7f3a
- Mode: Feature
- Branch: main
- Worktree: D:\Datas\OthersProjects\openmaic
- Base commit: a76c8d2613c6ab6e0c661fbfd574803c2b09fc44
- Owner: developer
- Status: Ready for integration
## Scope
- Diagnose the Jenkins/Docker failure at `OpenMAIC/Dockerfile:64` (`RUN pnpm build`).
- Reproduce the repository's production webpack build where the local environment permits,
and distinguish a source/build regression from a runner resource or timeout failure.
- Do not change application or Docker build behavior without the missing Jenkins/Docker
termination evidence.
## Intent And Constraints
- The supplied log stops after `Creating an optimized production build ...` and only shows
a bare `ELIFECYCLE Command failed`; it does not contain the terminating signal or compiler
diagnostic.
- The repository's `pnpm build` first requires the generated
`public/vendor/maic-importer/index.js`; the Docker dependency stage normally creates it via
postinstall, so a missing local copy must not be confused with the reported Docker failure.
- Preserve the clean source worktree; generated package dist files and `.next` output are
diagnostic artifacts only.
## Outcome
- The local Windows `pnpm build` initially stopped at the expected vendor guard because the
ignored postinstall artifact was absent. After generating ignored workspace dist outputs and
syncing the vendor bundle, the equivalent direct Next command completed successfully:
`node --max-old-space-size=8192 node_modules/next/dist/bin/next build --webpack`.
- The successful build compiled webpack in about 4.8 minutes, used roughly 5.7 GB working set
at peak sampling, then finished TypeScript, 56 static pages, traces, and standalone output.
- A second direct build with a 4096 MB V8 heap also completed successfully, but webpack took
about 5.4 minutes and the process used roughly 3.8–4.1 GB working set.
- The generated Next trace from the successful run records `run-webpack` at 326.806 seconds
and total `next-build` at 397.158 seconds; the trace and generated outputs were removed after
verification because they are ignored build artifacts.
- The middleware deprecation warning appeared in both successful builds and is not the failure.
- A subsequent Jenkins run again stopped at `#22 308.2` immediately after
`Creating an optimized production build ...`, with the same bare `ELIFECYCLE` and no
compiler/OOM diagnostic. The repeatable ~5-minute cutoff strengthens the external build-step
timeout hypothesis; it still does not identify the signal without Jenkins/Docker metadata.
- The evidence is consistent with a Jenkins/Docker memory ceiling or build-step timeout killing
webpack before it emits a compiler error. The exact external cause remains unverified because
the Docker daemon and Jenkins host logs are unavailable in this workspace.
- The build script in `OpenMAIC/package.json` now caps the V8 heap at 4096 MB instead of
8192 MB. This is a mitigation for the observed host-level memory pressure, not proof that
the external 5-minute termination was the sole cause.
## Verification
- `check_project_docs.py` passed.
- `task_context.py status --json` confirmed this task owns the clean main worktree.
- Direct Next webpack build with 8192 MB heap: passed, full route output and exit code 0.
- Direct Next webpack build with 4096 MB heap: passed, full route output and exit code 0.
- Read-only final diagnosis review: PASS; the reviewer agrees the evidence supports an
external timeout/resource termination hypothesis but cannot distinguish timeout from OOM.
- `git status --short --untracked-files=all`: only this task record remains untracked; temporary
generated source changes were restored.
- Docker daemon/engine is unavailable locally, so an end-to-end image build was not reproduced.
- Follow-up Jenkins log: same failure signature at approximately 308 seconds.
- The later diagnostic-script run ended with `ERROR: failed to solve: Canceled: context canceled`
and script exit code `124`; this is the script's own `timeout 900s`, not a compiler exit.
Its cgroup reported an effectively unlimited `memory.max` and `oom_kill 0`. The kernel output
contained a historical BuildKit Node OOM at 21:46:05 (about 6.3 GiB RSS), which proves the
7.3 GiB host has previously exhausted memory but is not timestamped to the 22:38 run.
- `OpenMAIC/package.json` parses successfully after the heap-cap change; `git diff --check`
reports no whitespace errors.
- Read-only implementation review: PASS; the reviewer found the one-line heap reduction and
proposed Jenkins observability/timeout wrapper consistent with the available evidence.
## Follow-ups
- Re-run Jenkins with untruncated output (`docker build --progress=plain`) and capture the final
30 lines plus the shell/Docker exit code.
- Check the build node/container memory limit (`/sys/fs/cgroup/memory.max`, `docker stats`, or
Jenkins host metrics) and whether the job has a five-minute command timeout. The repeated
~308-second cutoff makes that timeout the first check. Budget at least
6–8 GiB for this webpack build and a timeout above the observed ~6-minute end-to-end duration.
- Run the updated Jenkins command with `--progress=plain`, a 900-second per-image timeout, and
failure diagnostics for cgroup memory and kernel OOM evidence. Jenkins' own job timeout must
also exceed 15 minutes; a shell-level timeout cannot override a shorter Pipeline/plugin limit.
## Promotion Candidates
- None. This investigation does not establish a source or Docker configuration change without
the external termination signal.

View File

@@ -12,7 +12,7 @@
"gen:video-export-katex": "node scripts/generate-video-export-katex.mjs",
"gen:video-export-noto-cjk": "node scripts/generate-video-export-noto-cjk.mjs",
"dev": "next dev",
"build": "node scripts/assert-vendor-maic-importer.mjs && node --max-old-space-size=8192 node_modules/next/dist/bin/next build --webpack",
"build": "node scripts/assert-vendor-maic-importer.mjs && node --max-old-space-size=4096 node_modules/next/dist/bin/next build --webpack",
"build:learning-engine": "node scripts/build-learning-artifact.mjs engine",
"build:learning-ops": "node scripts/build-learning-artifact.mjs ops",
"build:makelore-player": "node scripts/build-learning-artifact.mjs player",