Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
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>
77 lines
3.2 KiB
Docker
77 lines
3.2 KiB
Docker
# ── Stage 1: Base ──────────────────────────────────────
|
|
FROM node:22-alpine AS base
|
|
RUN corepack enable && corepack prepare pnpm@10.29.3 --activate
|
|
WORKDIR /app
|
|
|
|
# ── Stage 2: Dependencies ─────────────────────────────
|
|
FROM base AS deps
|
|
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
|
|
COPY apps/api/package.json apps/api/package.json
|
|
COPY apps/web/package.json apps/web/package.json
|
|
COPY packages/shared/package.json packages/shared/package.json
|
|
COPY packages/config/package.json packages/config/package.json
|
|
COPY packages/ui/package.json packages/ui/package.json
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# ── Stage 3: Build ─────────────────────────────────────
|
|
FROM base AS build
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/apps/api/node_modules ./apps/api/node_modules
|
|
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
|
|
COPY --from=deps /app/packages/shared/node_modules ./packages/shared/node_modules
|
|
COPY --from=deps /app/packages/config/node_modules ./packages/config/node_modules
|
|
COPY --from=deps /app/packages/ui/node_modules ./packages/ui/node_modules
|
|
COPY . .
|
|
|
|
# Vite env vars (baked at build time)
|
|
ARG VITE_FARO_ENABLED=false
|
|
ARG VITE_FARO_COLLECTOR_URL=
|
|
ARG VITE_POSTHOG_KEY=
|
|
|
|
RUN pnpm build
|
|
|
|
# ── Stage 4: Production ───────────────────────────────
|
|
FROM node:22-alpine AS production
|
|
|
|
# Chromium for Playwright (EMEX/PartsCatalogs)
|
|
RUN apk add --no-cache chromium nss freetype harfbuzz ca-certificates ttf-freefont
|
|
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser
|
|
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy built artifacts
|
|
COPY --from=build /app/apps/api/dist ./apps/api/dist
|
|
COPY --from=build /app/apps/web/dist ./apps/web/dist
|
|
COPY --from=build /app/packages/shared/dist ./packages/shared/dist
|
|
COPY --from=build /app/packages/config/dist ./packages/config/dist
|
|
|
|
# Copy package files for production install
|
|
COPY --from=build /app/package.json ./
|
|
COPY --from=build /app/pnpm-lock.yaml ./
|
|
COPY --from=build /app/pnpm-workspace.yaml ./
|
|
COPY --from=build /app/apps/api/package.json ./apps/api/
|
|
COPY --from=build /app/apps/web/package.json ./apps/web/
|
|
COPY --from=build /app/packages/shared/package.json ./packages/shared/
|
|
COPY --from=build /app/packages/config/package.json ./packages/config/
|
|
COPY --from=build /app/packages/ui/package.json ./packages/ui/
|
|
|
|
# NestJS CLI config (needed for serve-static)
|
|
COPY --from=build /app/apps/api/nest-cli.json ./apps/api/
|
|
|
|
# Drizzle migrations + startup wrapper
|
|
COPY --from=build /app/apps/api/drizzle ./apps/api/drizzle
|
|
COPY --from=build /app/apps/api/start.sh ./apps/api/start.sh
|
|
|
|
# Runtime scripts (EMEX VIN scraper, etc.) loaded by EmexService via require()
|
|
COPY --from=build /app/scripts ./scripts
|
|
|
|
RUN corepack enable && corepack prepare pnpm@10.29.3 --activate \
|
|
&& pnpm install --frozen-lockfile --prod \
|
|
&& pnpm store prune
|
|
|
|
ENV NODE_ENV=production
|
|
EXPOSE 4000
|
|
|
|
CMD ["./apps/api/start.sh"]
|