From 959314e9db12343045ec800eb361c142430cd755 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Wed, 8 Apr 2026 21:52:24 -0700 Subject: [PATCH] =?UTF-8?q?ci(e2e):=20=F0=9F=91=B7=20Update=20Docker=20and?= =?UTF-8?q?=20docker-compose=20configurations=20for=20e2e=20testing=20envi?= =?UTF-8?q?ronment=20to=20optimize=20API/web=20service=20setup,=20dependen?= =?UTF-8?q?cies,=20and=20resource=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- @tooling/e2e/Dockerfile.api.e2e | 27 ++++++++++----------------- @tooling/e2e/Dockerfile.e2e | 25 +++++++++++++++++-------- @tooling/e2e/Dockerfile.web.e2e | 2 +- @tooling/e2e/docker-compose.e2e.yml | 20 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/@tooling/e2e/Dockerfile.api.e2e b/@tooling/e2e/Dockerfile.api.e2e index 3b105dc..807821e 100644 --- a/@tooling/e2e/Dockerfile.api.e2e +++ b/@tooling/e2e/Dockerfile.api.e2e @@ -1,19 +1,21 @@ -FROM node:22-slim AS build +FROM node:22-slim WORKDIR /app +RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/* + # Install pnpm RUN corepack enable && corepack prepare pnpm@9.0.0 --activate -# Copy workspace manifests -COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +# Copy workspace manifests for dependency resolution +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc* ./ COPY @packages/companion-client/package.json ./@packages/companion-client/ COPY @applications/api/package.json ./@applications/api/ COPY @applications/web/package.json ./@applications/web/ COPY @tooling/e2e/package.json ./@tooling/e2e/ -# Install all workspace deps (needed for pnpm workspace resolution) -RUN pnpm install --frozen-lockfile --ignore-scripts +# Install all workspace deps including devDeps (needed for swc-node register at runtime) +RUN pnpm install --frozen-lockfile # Copy source COPY @packages/companion-client ./@packages/companion-client @@ -23,16 +25,7 @@ COPY @applications/api ./@applications/api RUN pnpm --filter @lilith/companion-client build RUN pnpm --filter @companion/api build -FROM node:22-slim AS runtime +WORKDIR /app/@applications/api -WORKDIR /app - -# Install curl for healthcheck -RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/* - -COPY --from=build /app/@applications/api/dist ./dist -COPY --from=build /app/@applications/api/node_modules ./node_modules -COPY --from=build /app/node_modules /root_node_modules - -# Run migrations then start -CMD ["node", "dist/main.js"] +# NestJS SWC build emits .js-less imports; use the swc-node ESM register hook to resolve them +CMD ["node", "--import", "@swc-node/register/esm-register", "dist/main.js"] diff --git a/@tooling/e2e/Dockerfile.e2e b/@tooling/e2e/Dockerfile.e2e index 8eb9e97..bbd30c9 100644 --- a/@tooling/e2e/Dockerfile.e2e +++ b/@tooling/e2e/Dockerfile.e2e @@ -2,19 +2,28 @@ FROM mcr.microsoft.com/playwright:v1.50.0-jammy WORKDIR /app +# Install pnpm at workspace version RUN corepack enable && corepack prepare pnpm@9.0.0 --activate -# Copy e2e package files only -COPY @tooling/e2e/package.json ./package.json -COPY @tooling/e2e/pnpm-lock.yaml* ./ +# Copy workspace root manifests so pnpm can resolve the lockfile +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc* ./ -# Install playwright and test deps -RUN pnpm install --frozen-lockfile || pnpm install +# Copy all package.json files to let pnpm resolve workspace deps +COPY @packages/companion-client/package.json ./@packages/companion-client/ +COPY @applications/api/package.json ./@applications/api/ +COPY @applications/web/package.json ./@applications/web/ +COPY @tooling/e2e/package.json ./@tooling/e2e/ -COPY @tooling/e2e/playwright.config.ts ./playwright.config.ts -COPY @tooling/e2e/e2e ./e2e -COPY @tooling/e2e/tsconfig.json ./tsconfig.json +# Install all deps via workspace (needed for playwright and @lilith/playwright-e2e-docker) +RUN pnpm install --frozen-lockfile --filter @companion/e2e... + +# Copy e2e test files +COPY @tooling/e2e/playwright.config.ts ./@tooling/e2e/playwright.config.ts +COPY @tooling/e2e/e2e ./@tooling/e2e/e2e +COPY @tooling/e2e/tsconfig.json ./@tooling/e2e/tsconfig.json ENV CI=true +WORKDIR /app/@tooling/e2e + CMD ["npx", "playwright", "test", "--reporter=list"] diff --git a/@tooling/e2e/Dockerfile.web.e2e b/@tooling/e2e/Dockerfile.web.e2e index 4906588..2a30a65 100644 --- a/@tooling/e2e/Dockerfile.web.e2e +++ b/@tooling/e2e/Dockerfile.web.e2e @@ -4,7 +4,7 @@ WORKDIR /app RUN corepack enable && corepack prepare pnpm@9.0.0 --activate -COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc* bunfig.toml* ./ COPY @packages/companion-client/package.json ./@packages/companion-client/ COPY @applications/api/package.json ./@applications/api/ COPY @applications/web/package.json ./@applications/web/ diff --git a/@tooling/e2e/docker-compose.e2e.yml b/@tooling/e2e/docker-compose.e2e.yml index c7072f9..86c09d5 100644 --- a/@tooling/e2e/docker-compose.e2e.yml +++ b/@tooling/e2e/docker-compose.e2e.yml @@ -10,6 +10,19 @@ # Or via the run script: # ./run e2e:docker +# LAN registry hosts (forge.black.local, npm.black.local → 10.0.0.11) +x-lan-hosts: &lan-hosts + extra_hosts: + - "forge.black.local:10.0.0.11" + - "npm.black.local:10.0.0.11" + +x-lan-build: &lan-build + args: + - BUILDKIT_SANDBOX_HOSTNAME=builder + extra_hosts: + - "forge.black.local:10.0.0.11" + - "npm.black.local:10.0.0.11" + services: e2e-postgres: image: postgres:16-alpine @@ -34,15 +47,18 @@ services: start_period: 5s companion-api: + <<: *lan-hosts build: context: ../.. dockerfile: "./@tooling/e2e/Dockerfile.api.e2e" + <<: *lan-build environment: NODE_ENV: test API_PORT: '3850' DATABASE_URL: "postgresql://companion:companion@e2e-postgres:5432/companion_test" REDIS_URL: "redis://e2e-redis:6379" CHAT_MODEL: stub + DATABASE_SYNCHRONIZE: 'true' VAPID_PUBLIC_KEY: "BDummyPublicKeyForE2ETestsOnlyNotRealVapidKey00000000000000000000000000000000=" VAPID_PRIVATE_KEY: "DummyPrivateKeyForE2ETestsOnlyNotReal000=" VAPID_SUBJECT: "mailto:test@example.com" @@ -60,9 +76,11 @@ services: start_period: 15s companion-web: + <<: *lan-hosts build: context: ../.. dockerfile: "./@tooling/e2e/Dockerfile.web.e2e" + <<: *lan-build healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:5850/'] interval: 5s @@ -71,9 +89,11 @@ services: start_period: 10s e2e-tests: + <<: *lan-hosts build: context: ../.. dockerfile: "./@tooling/e2e/Dockerfile.e2e" + <<: *lan-build depends_on: companion-api: condition: service_healthy