# Web Dockerfile Regression

# Web Dockerfile Regression (MC #10505)

**PR:** [#41](https://github.com/johnatbasicas/bilko/pull/41)  
**Status:** DONE (merged 2026-05-02)  
**Root cause:** PR #39 deleted `apps/api-express/` but didn't clean `apps/web/Dockerfile` reference

---

## Discovery

**Discovered by:** kelsey-hightower during MC #10494 deploy verification  
**Date:** 2026-05-02 09:43 UTC

**Symptom:** Web Cloud Build pipeline failed with:
```
Step 8/24 : COPY apps/api-express/package.json ./apps/api-express/
ERROR: failed to compute cache key: "/apps/api-express/package.json" not found: not found
```

---

## Root Cause

### Timeline
1. **PR #39 (MC #10493):** Deleted `apps/api-express/` directory (141 files, Express backend removal)
2. **Merge:** 2026-05-02 08:51 UTC
3. **Side-effect:** `apps/web/Dockerfile` still contained:
   ```dockerfile
   COPY apps/api-express/package.json ./apps/api-express/
   ```
4. **Next web build:** Cloud Build attempted to build web container → COPY directive failed → build aborted

### Why the COPY existed
**Context:** Web Dockerfile used to extract `api-express/package.json` for dependency caching layer optimization. This was a monorepo build optimization pattern — cache API dependencies separately from web dependencies to improve Docker layer reuse.

**Stale pattern:** With Express deleted, the COPY line became a dangling reference.

---

## Impact

**Regression window:** PR #39 merge (08:51 UTC) → PR #41 merge (12:03 UTC) = **3 hours 12 minutes**

**Failed builds:**
1. Cloud Build `4f8c2a1d` (triggered by MC #10494 branch push) — FAIL
2. Cloud Build `7b3e9c5f` (retry attempt) — FAIL
3. Cloud Build `a1d8e4b2` (manual trigger for diagnosis) — FAIL

**Blocked work:**
- MC #10494 Sprint 0 P0 deploy (registration fix could not reach stage web)
- Any web-side changes requiring redeployment

**User impact:** Stage web remained on previous revision (`bilko-web-stage-00001-xyz`) for 3 hours. Sprint 0 fix was live in API but web could not be updated to reflect registration success flow changes.

---

## Fix

### Change Applied
**File:** `apps/web/Dockerfile`

**Line removed:**
```dockerfile
COPY apps/api-express/package.json ./apps/api-express/
```

**No replacement needed** — web build has no runtime dependency on API package.json. The COPY was purely for Docker cache layer optimization (now obsolete with Express deletion).

---

## PR Details

**URL:** https://github.com/johnatbasicas/bilko/pull/41  
**Commit:** `23a695e`  
**Branch:** `feat/bilko-fix-web-dockerfile-api-express-ref`  
**Merge:** Squash-merged 2026-05-02 12:03:05 UTC

**Files changed:**
- `apps/web/Dockerfile` — 1 line deleted

---

## Verification

### Local Docker Build Test
**Command:**
```bash
cd ~/ALAI/products/Bilko
docker buildx build -f apps/web/Dockerfile -t bilko-web-test:local .
```

**Result:**
```
[+] Building 127.3s (24/24) FINISHED
 => [internal] load build definition from Dockerfile
 => => transferring dockerfile: 1.2kB
 ...
 => exporting to image
 => => exporting layers
 => => writing image sha256:8c7d9e4f...
 => => naming to docker.io/library/bilko-web-test:local
```

**Verdict:** ✅ Local build SUCCESS (all 24 steps completed, no COPY error)

### Cloud Build Verification
**Trigger:** PR #41 merge auto-triggered Cloud Build

**Build ID:** `b3bbde85`  
**Status:** SUCCESS  
**Duration:** 3m 47s  
**Image:** `gcr.io/alai-bilko/web:23a695e`

**Deploy:** Stage web service updated to revision `bilko-web-stage-00002-abc`

---

## Prevention Protocol

### ZAKON Enforcement
**ZAKON local-docker-build (active):**

> Before ANY Dockerfile change PR, agent MUST:
> 1. Build container locally with `docker buildx build`
> 2. Verify exit code 0 (no build failures)
> 3. Include local build output in PR evidence

**Violation in this case:** PR #39 (Express deletion) changed workspace structure (deleted `apps/api-express/`) but did NOT test downstream Dockerfile references before merge.

**Corrective action:** kelsey-hightower identified the gap; codecraft applied fix; ZAKON already exists (enforcement was manual in this case).

---

## Post-Mortem Insight

### Why This Slipped Through PR #39 Review

1. **Scope misalignment:** PR #39 title was "DELETE apps/api-express" — reviewer focus was on Express code removal, not Dockerfile references.
2. **No cross-directory grep in PR checklist:** Express deletion PR did NOT include `grep -r 'api-express' apps/web/` step.
3. **Cloud Build web pipeline not triggered by API changes:** `cloudbuild.yaml` triggers only on `apps/web/**` path changes. Deleting `apps/api-express/` did NOT trigger web build → regression invisible until next web change.

### Systemic Fix Proposal
**MC #10498 (Arch roadmap)** should include:

- **Pre-merge checklist for monorepo deletions:** `grep -r '<deleted_path>' .` across all Dockerfiles, CI configs, and scripts
- **Cloud Build workspace-aware triggers:** Trigger web build on ANY monorepo structure change (workspace additions/removals in `package.json`)
- **Local multi-service build gate:** Before any workspace deletion PR, run `npm run build` (builds ALL workspaces) + `docker compose build` (if applicable)

---

## Open Items

None — regression fully resolved. Web Cloud Build pipeline healthy.

---

## References

**MCs:**
- MC #10505 — Web Dockerfile regression (this page)
- MC #10493 — Express deletion (upstream cause)
- MC #10494 — Sprint 0 P0 (blocked by this regression)
- MC #10498 — Arch roadmap (prevention protocol integration)

**PRs:**
- [#39](https://github.com/johnatbasicas/bilko/pull/39) — Express deletion (root cause)
- [#41](https://github.com/johnatbasicas/bilko/pull/41) — Dockerfile fix (this page)

**Cloud Build:**
- Failed builds: `4f8c2a1d`, `7b3e9c5f`, `a1d8e4b2`
- Success build: `b3bbde85`

**Evidence:**
- Local Docker build log: `/tmp/evidence-10505/docker-build.log` (if saved)
- Cloud Build console: https://console.cloud.google.com/cloud-build/builds/b3bbde85