Add PostgreSQL-backed background worker

This commit is contained in:
2026-08-17 01:02:44 -04:00
parent 9929d7321d
commit 24a1307a96
22 changed files with 629 additions and 120 deletions
+27
View File
@@ -6,10 +6,19 @@ WORKDIR /app
FROM base AS install
COPY package.json bun.lock ./
COPY apps/web/package.json apps/web/package.json
COPY apps/worker/package.json apps/worker/package.json
COPY apps/mobile/package.json apps/mobile/package.json
COPY packages/domain/package.json packages/domain/package.json
RUN bun install --frozen-lockfile --filter @beenvoice/web
FROM base AS worker-install
COPY package.json bun.lock ./
COPY apps/web/package.json apps/web/package.json
COPY apps/worker/package.json apps/worker/package.json
COPY apps/mobile/package.json apps/mobile/package.json
COPY packages/domain/package.json packages/domain/package.json
RUN bun install --frozen-lockfile --filter @beenvoice/worker
# Next's production build runs under Node because Bun can fail during the
# page-data worker phase on Linux arm64. Dependencies still come from Bun.
FROM node:22-bookworm-slim AS build
@@ -55,3 +64,21 @@ USER bun
EXPOSE 3000
WORKDIR /app/apps/web
CMD ["sh", "-c", "bun src/server/db/migrate.ts && bun run start"]
FROM base AS worker
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1
COPY --from=worker-install /app ./
COPY apps/web/src ./apps/web/src
COPY apps/web/tsconfig.json ./apps/web/tsconfig.json
COPY apps/worker ./apps/worker
COPY packages/domain ./packages/domain
RUN ln -s ../worker/node_modules apps/web/node_modules
USER bun
WORKDIR /app/apps/worker
CMD ["bun", "run", "start"]
# Keep the web application as the default Dockerfile target.
FROM release AS final