# Image für den Dienst `worker`. Hängt am Discord-Gateway und hält die # Guild-Mitgliedschaft in Postgres aktuell, siehe docs/02-architektur.md. ARG NODE_VERSION=22-alpine ARG PNPM_VERSION=9.15.4 FROM node:${NODE_VERSION} AS deps ARG PNPM_VERSION RUN npm install -g pnpm@${PNPM_VERSION} WORKDIR /repo COPY pnpm-workspace.yaml package.json pnpm-lock.yaml .npmrc ./ COPY packages/db/package.json packages/db/ COPY web/package.json web/ COPY worker/package.json worker/ COPY pdf/package.json pdf/ RUN pnpm install --frozen-lockfile --filter @afis/worker... --filter @afis/db... FROM node:${NODE_VERSION} AS build ARG PNPM_VERSION RUN npm install -g pnpm@${PNPM_VERSION} WORKDIR /repo COPY --from=deps /repo/node_modules ./node_modules COPY --from=deps /repo/packages/db/node_modules ./packages/db/node_modules COPY --from=deps /repo/worker/node_modules ./worker/node_modules COPY . . RUN pnpm --filter @afis/db build && pnpm --filter @afis/worker build && \ pnpm --filter @afis/worker --prod --no-optional deploy /bundle && \ cp -r worker/dist /bundle/dist && \ cp worker/healthcheck.js /bundle/healthcheck.js FROM node:${NODE_VERSION} AS runtime WORKDIR /app ENV NODE_ENV=production RUN apk add --no-cache openssl && \ addgroup -g 1001 -S afis && \ adduser -u 1001 -S afis -G afis COPY --from=build --chown=afis:afis /bundle ./ USER afis HEALTHCHECK --interval=60s --timeout=10s --start-period=30s --retries=3 \ CMD node healthcheck.js || exit 1 CMD ["node", "dist/index.js"]