fix(emex): ship runtime scripts/ in prod image and forward chromium executable path #25

Merged
root merged 1 commits from fix-emex-scraper-prod-image into main 2026-05-18 08:45:39 +03:00
Owner

Two prod-image fixes — EMEX leaf parts have been silently empty for users.

  1. scripts/emex-vin-scraper.js was never copied to the production image — Dockerfile production stage cherry-picks dist/drizzle/start.sh only. EmexService.doInitialize fails with Scraper file not found at: /app/scripts/... on every leaf request.
  2. PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH env var is consumed only by playwright install, not at runtime. Forward it explicitly to chromium.launch() so Alpine prod image uses the system chromium at /usr/bin/chromium-browser instead of looking for the missing bundled headless-shell.

Repro: VIN NLAES75204W300895 (Honda Civic, emex-decoded) → any leaf category showed 0 parça listeleniyor. Root cause traced via prod api logs (Scraper file not found at: /app/scripts/emex-vin-scraper.js).

Two prod-image fixes — EMEX leaf parts have been silently empty for users. 1. `scripts/emex-vin-scraper.js` was never copied to the production image — Dockerfile production stage cherry-picks dist/drizzle/start.sh only. EmexService.doInitialize fails with `Scraper file not found at: /app/scripts/...` on every leaf request. 2. `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH` env var is consumed only by `playwright install`, not at runtime. Forward it explicitly to `chromium.launch()` so Alpine prod image uses the system chromium at `/usr/bin/chromium-browser` instead of looking for the missing bundled headless-shell. Repro: VIN `NLAES75204W300895` (Honda Civic, emex-decoded) → any leaf category showed `0 parça listeleniyor`. Root cause traced via prod api logs (`Scraper file not found at: /app/scripts/emex-vin-scraper.js`).
root added 1 commit 2026-05-18 08:45:38 +03:00
fix(emex): ship runtime scripts/ in prod image and forward chromium executable path
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
a1e80c042f
EMEX-decoded vehicles surfaced empty category pages on prod because two
runtime prerequisites were absent from the production image:

1. `scripts/emex-vin-scraper.js` was never copied — the build stage's
   `COPY . .` brings it in but the production stage only cherry-picks
   `apps/api/dist`, `drizzle`, and `start.sh`. Every EMEX leaf hit
   therefore failed with "Scraper file not found at: /app/scripts/…"
   and the category page rendered "Bu kategori icin parca bulunamadi."
2. `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser` was
   exported in the Dockerfile but never reached `chromium.launch()` —
   that env var is consumed by `playwright install`, not at runtime.
   Playwright fell back to its bundled headless-shell cache path
   (`/root/.cache/ms-playwright/chromium_headless_shell-*/…`) which
   does not exist on the alpine image, so even with the scraper file
   present the browser pool init would have kept failing.

Fix:
- Dockerfile: `COPY --from=build /app/scripts ./scripts`.
- `emex.browser.ts` + `parts-catalogs-auth.service.ts`: read
  `process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH` and pass it as
  `executablePath` to `chromium.launch()` when set.

Verified on prod container: `ls /app/scripts` → missing pre-fix; the
binary at `/usr/bin/chromium-browser` exists, so the env-var hand-off
will resolve cleanly once the new image lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
root merged commit ee8760eb33 into main 2026-05-18 08:45:39 +03:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: root/sase.tr#25