Browse Source

fix reusable-app-prod.yml

Yuki Takei 2 weeks ago
parent
commit
16407530fd

+ 1 - 0
.github/workflows/reusable-app-prod.yml

@@ -68,6 +68,7 @@ jobs:
       run: |
       run: |
         tar -zcf production.tar.gz --exclude ./apps/app/.next/cache \
         tar -zcf production.tar.gz --exclude ./apps/app/.next/cache \
           package.json \
           package.json \
+          node_modules \
           apps/app/.next \
           apps/app/.next \
           apps/app/config \
           apps/app/config \
           apps/app/dist \
           apps/app/dist \

+ 23 - 1
.kiro/specs/optimise-deps-for-prod-with-turbo-prune/design.md

@@ -36,7 +36,7 @@ This design removes both root causes: in pnpm v10, `pnpm deploy --legacy` alread
 | Requirement | Summary | Components | Flows |
 | Requirement | Summary | Components | Flows |
 |-------------|---------|------------|-------|
 |-------------|---------|------------|-------|
 | 1.1–1.4 | Eliminate symlink rewrite steps | `assemble-prod.sh` | Assembly Flow |
 | 1.1–1.4 | Eliminate symlink rewrite steps | `assemble-prod.sh` | Assembly Flow |
-| 2.1–2.4 | `pnpm deploy --prod` (no `--legacy`) creates prod-only workspace-root `node_modules/` | `assemble-prod.sh` | Assembly Flow |
+| 2.1–2.4 | `pnpm deploy --prod --legacy` creates prod-only workspace-root `node_modules/` (self-contained in pnpm v10) | `assemble-prod.sh` | Assembly Flow |
 | 3.1–3.4 | Release artifact has `node_modules/` at workspace root; `apps/app/node_modules` is a symlink | `assemble-prod.sh`, Dockerfile staging | Assembly Flow, Release Image |
 | 3.1–3.4 | Release artifact has `node_modules/` at workspace root; `apps/app/node_modules` is a symlink | `assemble-prod.sh`, Dockerfile staging | Assembly Flow, Release Image |
 | 4.1–4.5 | Production server starts, `GET /` returns 200, no broken symlinks | All components | Validation |
 | 4.1–4.5 | Production server starts, `GET /` returns 200, no broken symlinks | All components | Validation |
 | 5.1–5.5 | `pruner` stage unchanged; Docker layer caching preserved | Dockerfile | Build Flow |
 | 5.1–5.5 | `pruner` stage unchanged; Docker layer caching preserved | Dockerfile | Build Flow |
@@ -182,6 +182,7 @@ graph LR
 | `assemble-prod.sh` | Build Assembly | Assemble prod artifact: deploy prod deps, stage symlinks, clean | 1.1–1.4, 2.1–2.4, 3.1–3.3 | pnpm, filesystem | Batch |
 | `assemble-prod.sh` | Build Assembly | Assemble prod artifact: deploy prod deps, stage symlinks, clean | 1.1–1.4, 2.1–2.4, 3.1–3.3 | pnpm, filesystem | Batch |
 | Dockerfile `builder` staging step | Container Build | Copy release artifact to `/tmp/release/` with correct structure | 3.1, 3.3, 5.1–5.3 | Docker BuildKit COPY | Batch |
 | Dockerfile `builder` staging step | Container Build | Copy release artifact to `/tmp/release/` with correct structure | 3.1, 3.3, 5.1–5.3 | Docker BuildKit COPY | Batch |
 | Release image structure | Container Runtime | `node_modules/` at workspace root; `apps/app/node_modules` symlink | 3.2, 3.4, 4.1–4.4 | `assemble-prod.sh` output | State |
 | Release image structure | Container Runtime | `node_modules/` at workspace root; `apps/app/node_modules` symlink | 3.2, 3.4, 4.1–4.4 | `assemble-prod.sh` output | State |
+| `reusable-app-prod.yml` archive step | CI Pipeline | Archive workspace-root `node_modules/` + `apps/app/node_modules` symlink for `launch-prod` and Playwright jobs | 4.3, 4.5 | `assemble-prod.sh` output, GitHub Actions `tar` | Batch |
 
 
 ### Build Assembly
 ### Build Assembly
 
 
@@ -296,6 +297,27 @@ The `release` stage copies `/tmp/release/` to `${appDir}` (e.g. `/opt/growi/`):
 
 
 ---
 ---
 
 
+### CI Pipeline
+
+#### `.github/workflows/reusable-app-prod.yml` — `archive-prod-files` step
+
+| Field | Detail |
+|-------|--------|
+| Intent | Archive the complete production artifact (workspace-root `node_modules/` + `apps/app/` contents) so that `launch-prod` and `run-playwright` jobs can extract a self-contained release |
+| Requirements | 4.3, 4.5 |
+
+**Responsibilities & Constraints**
+- Include workspace-root `node_modules/` in the tarball (prod-only, from `assemble-prod.sh` output)
+- Include `apps/app/node_modules` as a symlink (preserved by `tar` default behaviour — no `--dereference`)
+- When extracted, the structure must satisfy: `apps/app/node_modules → ../../node_modules` resolves to the extracted workspace-root `node_modules/`
+
+**Implementation Notes**
+- Add `node_modules \` immediately before `apps/app/.next \` in the `tar -zcf` command
+- `tar` archives symlinks without following them by default; `apps/app/node_modules` is correctly preserved as a symlink pointing to `../../node_modules`
+- The extraction in both `launch-prod` (`tar -xf`) and `run-playwright` (`tar -xf ... -C /tmp/growi-prod`) restores the symlink; `../../node_modules` resolves correctly because workspace-root `node_modules/` is now also extracted
+
+---
+
 ## Testing Strategy
 ## Testing Strategy
 
 
 ### Production Server Startup Procedure (updated)
 ### Production Server Startup Procedure (updated)

+ 10 - 0
.kiro/specs/optimise-deps-for-prod-with-turbo-prune/tasks.md

@@ -7,6 +7,7 @@
 | 1 | Verify `pnpm deploy --legacy` symlink behavior in pnpm v10 | 1.1 | 2.1, 2.2, 2.3 |
 | 1 | Verify `pnpm deploy --legacy` symlink behavior in pnpm v10 | 1.1 | 2.1, 2.2, 2.3 |
 | 2 | Simplify `assemble-prod.sh` | 2.1, 2.2 | 1.1–1.4, 2.1, 2.4, 3.1–3.3, 5.4, 5.5 |
 | 2 | Simplify `assemble-prod.sh` | 2.1, 2.2 | 1.1–1.4, 2.1, 2.4, 3.1–3.3, 5.4, 5.5 |
 | 3 | Update Dockerfile staging | — | 3.1, 3.3, 5.1–5.3 |
 | 3 | Update Dockerfile staging | — | 3.1, 3.3, 5.1–5.3 |
+| 3b | Update CI workflow archive step | — | 4.3, 4.5 |
 | 4 | Validate end-to-end | 4.1, 4.2, 4.3 | 1.1–1.4, 2.3, 2.4, 3.2, 3.4, 4.1–4.5, 6.1–6.4 |
 | 4 | Validate end-to-end | 4.1, 4.2, 4.3 | 1.1–1.4, 2.3, 2.4, 3.2, 3.4, 4.1–4.5, 6.1–6.4 |
 
 
 ---
 ---
@@ -59,6 +60,15 @@
 
 
 ---
 ---
 
 
+- [x] 3b. Update CI workflow archive step to include workspace-root `node_modules/`
+  - In `.github/workflows/reusable-app-prod.yml`, in the `build-prod` job `archive-prod-files` step, add `node_modules \` immediately before `apps/app/.next \` in the `tar -zcf` command
+  - With the new `assemble-prod.sh`, `apps/app/node_modules` is a symlink to `../../node_modules`. Without this change, `launch-prod` and `run-playwright` extract a broken symlink (the target `../../node_modules` is absent from the tarball)
+  - `tar` preserves symlinks by default (no `--dereference`): `apps/app/node_modules` is archived and extracted as a symlink; workspace-root `node_modules/` is archived and extracted as a real directory — `../../node_modules` resolves correctly after extraction
+  - Verify the tarball contents: `tar -tzf production.tar.gz | grep -E '^node_modules/$'` should show `node_modules/`
+  - _Requirements: 4.3, 4.5_
+
+---
+
 - [ ] 4. Validate the simplified assembly pipeline end-to-end
 - [ ] 4. Validate the simplified assembly pipeline end-to-end
 
 
 - [ ] 4.1 Run the updated `assemble-prod.sh` and verify symlink integrity
 - [ ] 4.1 Run the updated `assemble-prod.sh` and verify symlink integrity