一键导入
docker-multi-stage-dist-overwrite
Fix Docker multi-stage build where COPY . . overwrites fresh dist/ with stale host files due to missing .dockerignore
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Fix Docker multi-stage build where COPY . . overwrites fresh dist/ with stale host files due to missing .dockerignore
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | docker-multi-stage-dist-overwrite |
| description | Fix Docker multi-stage build where COPY . . overwrites fresh dist/ with stale host files due to missing .dockerignore |
When using Docker multi-stage builds with npm run build in the build stage, the COPY . . instruction copies the HOST's existing dist/ folder into the container after npm run build has already run, overwriting the freshly built files with stale ones.
Symptoms:
npm run build inside the container runs and reports success (✅ built in Xs)Root cause:
.dockerignore file existed, so COPY . . (which copies the entire build context) includes dist/ from the hostCOPY . . layer is cached, so RUN npm run build is skippeddist/ from the host context winsCreate a .dockerignore in the project root (same directory as docker-compose.yml and Dockerfile):
node_modules
dist
.git
*.log
.env
.env.*
This prevents the host's dist/ from being sent as part of the Docker build context, forcing the build stage to always run npm run build from scratch.
docker compose build --no-cache does NOT help here because the cache that's being hit is the COPY . . layer (which copies the build context including stale dist/), NOT the RUN npm run build layer.
After building, verify the image contains the correct code:
# Check file content
sudo docker run --rm <image_name> grep -l "ComponentName" /path/to/assets/*.js
# Check timestamps
sudo docker run --rm <image_name> ls -la /path/to/assets/
# Should show recent timestamps (not old ones from host)
# Check container is actually running new image
sudo docker ps
sudo docker inspect <container_name> --format '{{.Image}}'
# Image SHA should match the newly built image SHA
Running npm run build locally BEFORE docker build does NOT help if the build context still includes the old dist/. The .dockerignore is the only real fix.
references/multi-stage-builder-reuse-node-modules.md — The modern pattern for slim runtime images: copy builder's node_modules directly into the runtime stage instead of re-installing with --production. Avoids duplicate install + layer bloat + Prisma dependency drift. Verified -22MB on pm-system 2026-06-09.Dev-agent / checker-agent collaboration loop driven by downstream project docs/STATE.md. Dev agent implements and records work items; an independent checker agent verifies each item with real lint/typecheck/test/build evidence and writes findings back; loop continues until all items are VERIFIED or escalation limits are hit.
Synchronizes review feedback, QA findings, user corrections, and code-review suggestions into durable project docs before Build, merge, or ship.
Intake workflow for existing projects before continuing development. Analyze current source state, derive a truthful docs baseline, identify QA/regression gaps, and create a safe continuation plan.
防止修復過的 bug 重新出現(regression)。 規則:每個修過的 bug 必須留下「regression test」+「root cause note」+「為何會發生」分析, 確保日後 refactor / 改需求時唔會重新踩坑。 David 在 2026-06-06 kanban task 明確指出「舊的 bug 又出現」嘅困擾。
定時壓縮長時間任務的 context,避免 token 爆炸。寫入 context-summary.md 保留決策和當前狀態,丢棄細節。
Task Orchestration Subagent — Coordinates all subagents, manages task board, handles parallel/sequential execution, tracks dependencies and failures. The conductor of the development orchestra.