Merge pull request #25 — fix(emex): scripts/ + chromium executablePath

This commit was merged in pull request #25.
This commit is contained in:
2026-05-18 05:45:39 +00:00
3 changed files with 20 additions and 2 deletions

View File

@@ -63,6 +63,9 @@ COPY --from=build /app/apps/api/nest-cli.json ./apps/api/
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

View File

@@ -165,6 +165,12 @@ export class EmexBrowserService implements OnModuleInit, OnModuleDestroy {
// Dynamic import — playwright is a devDependency
const { chromium } = await import("playwright");
// PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH only influences `playwright install`;
// chromium.launch() at runtime ignores it unless we forward it explicitly.
// Alpine images don't ship the bundled chromium-headless-shell that
// Playwright otherwise looks for under /root/.cache/ms-playwright/, so
// without this hand-off the production container fails with
// "Executable doesn't exist at …chrome-headless-shell".
const launchOptions: Record<string, unknown> = {
headless: true,
args: [
@@ -175,6 +181,8 @@ export class EmexBrowserService implements OnModuleInit, OnModuleDestroy {
"--disable-gpu",
],
};
const executablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
if (executablePath) launchOptions.executablePath = executablePath;
if (this.useProxy) {
const port = this.randomProxyPort();

View File

@@ -615,7 +615,10 @@ export class PartsCatalogsAuthService implements OnModuleInit, OnModuleDestroy {
private async _doLaunch(): Promise<void> {
const { chromium } = await import("playwright");
this.browser = await chromium.launch({
// See emex.browser.ts:_doLaunch — PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH is
// a `playwright install` knob, not a launch knob, so forward it manually
// for Alpine production where the bundled headless shell isn't installed.
const launchOptions: Record<string, unknown> = {
headless: true,
args: [
"--no-sandbox",
@@ -624,7 +627,11 @@ export class PartsCatalogsAuthService implements OnModuleInit, OnModuleDestroy {
"--disable-accelerated-2d-canvas",
"--disable-gpu",
],
});
};
const executablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
if (executablePath) launchOptions.executablePath = executablePath;
this.browser = await chromium.launch(launchOptions);
this.browser.on("disconnected", () => {
this.logger.warn("Browser disconnected — will relaunch on next request");