ci(e2e): 👷 Update Docker and docker-compose configurations for e2e testing environment to optimize API/web service setup, dependencies, and resource management

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-04-08 21:52:24 -07:00
parent 233d3aa126
commit 959314e9db
4 changed files with 48 additions and 26 deletions

View file

@ -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"]

View file

@ -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"]

View file

@ -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/

View file

@ -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