# apps/worker — headless BullMQ worker + domain-event stream consumers. # # WORKSPACE NOTE: this app is part of a pnpm monorepo (pnpm-workspace.yaml: # apps/*) and has a `workspace:*` dependency (@factory/shared) plus the shared # Prisma client from prisma/. A monorepo package cannot be built in isolation, # so build from the repository root with context at the root: # # docker build -f apps/worker/Dockerfile -t factory-worker . # # The image has no business HTTP surface — the only port it listens on is the # health server (TASK-0009 item 4): EXPOSE 4003 (/health + /health/ready). # It talks to Redis (BullMQ + factory:events streams), Postgres, OpenSearch, # S3, SMTP, ClamAV and the AI endpoint via environment (see .env.example). FROM node:20-alpine AS build WORKDIR /repo RUN corepack enable # Full monorepo source (a .dockerignore at the repo root should exclude # node_modules, dist, .git and app data so this stays lean). COPY . . RUN pnpm install --filter @factory/worker... \ && pnpm --filter @factory/worker exec prisma generate \ && pnpm --filter @factory/worker build FROM node:20-alpine AS runtime ENV NODE_ENV=production # Keep the monorepo layout so pnpm's relative node_modules symlinks resolve. WORKDIR /repo COPY --from=build /repo ./ WORKDIR /repo/apps/worker # Health server only (no business HTTP). Set WORKER_ID uniquely per replica. EXPOSE 4003 CMD ["node", "dist/index.js"]