From d3d7cf4f91555c250d18f3684ec0a005b3baec48 Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Sun, 19 Apr 2026 09:35:02 +0900 Subject: [PATCH] fix: reap HEALTHCHECK zombies by running tini as PID 1 The Dockerfile's CMD uses `exec pnpm start`, which makes Node.js PID 1 inside the container. Node.js only reaps children it spawned via `child_process`; it does not install a generic waitpid reaper, so processes spawned into the container by other means (notably the `HEALTHCHECK` curl firing every 10s) accumulate as `` zombies under PID 1. Over days, hundreds of `[curl] ` build up. Install tini and set it as ENTRYPOINT so it reaps any orphaned child regardless of origin while still forwarding signals to Node. --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ed936508f6..4aa6931588 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ WORKDIR /app # Set production ENV NODE_ENV=production -RUN apt-get update && apt-get install -y curl unzip zip apache2-utils iproute2 rsync git-lfs && git lfs install && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y tini curl unzip zip apache2-utils iproute2 rsync git-lfs && git lfs install && rm -rf /var/lib/apt/lists/* # Copy only the necessary files COPY --from=build /prod/dokploy/.next ./.next @@ -69,4 +69,6 @@ EXPOSE 3000 HEALTHCHECK --interval=10s --timeout=3s --retries=10 \ CMD curl -fs http://localhost:3000/api/trpc/settings.health || exit 1 - CMD ["sh", "-c", "pnpm run wait-for-postgres && exec pnpm start"] +# tini reaps HEALTHCHECK child processes that Node (as PID 1) leaves defunct. +ENTRYPOINT ["/usr/bin/tini", "--"] +CMD ["sh", "-c", "pnpm run wait-for-postgres && exec pnpm start"]