From 1e09a20aa1d896b1af157b8a82a7437ce03daa37 Mon Sep 17 00:00:00 2001 From: Nick Oliver Date: Fri, 12 Apr 2024 18:12:47 -0700 Subject: [PATCH 1/2] fix(server): handle kernel signals by including tini https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md\#handling-kernel-signals --- Dockerfile | 4 ++++ scripts/start.sh | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b0efb5f3a..195840196 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,8 @@ RUN NODE_ENV=production npm run build && \ # development image # docker build . --target=development FROM node:$VERSION-alpine as development +# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals +RUN apk add --no-cache tini ARG USER ENV USER ${USER:-node} ENV NODE_ENV=development @@ -50,6 +52,8 @@ COPY --from=builder --chown=node:node /opt/one-app/development ./ # production image # last so that it's the default image artifact FROM node:$VERSION-alpine as production +# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals +RUN apk add --no-cache tini ARG USER ENV USER ${USER:-node} ENV NODE_ENV=production diff --git a/scripts/start.sh b/scripts/start.sh index c83073c04..9045b7400 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -35,5 +35,5 @@ done commandArgs="$nodeArgs lib/server/index.js $flags" -echo "node $commandArgs" -exec node $commandArgs +echo "/sbin/tini -- node $commandArgs" +exec /sbin/tini -- node $commandArgs From fe13e5a41e0d968dcb9cef111b499aa098e7ba89 Mon Sep 17 00:00:00 2001 From: Nick Oliver Date: Tue, 16 Apr 2024 08:28:07 -0700 Subject: [PATCH 2/2] fix(image): use tini as the entrypoint revert changes to the start.sh script --- Dockerfile | 13 +++++++------ scripts/start.sh | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 195840196..d21691d50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,11 +29,14 @@ RUN NODE_ENV=production npm run build && \ mv /opt/build/bundle.integrity.manifest.json /opt/one-app/production && \ mv /opt/build/.build-meta.json /opt/one-app/production -# development image -# docker build . --target=development -FROM node:$VERSION-alpine as development # https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals +FROM node:$VERSION-alpine as node-tini RUN apk add --no-cache tini +ENTRYPOINT ["/sbin/tini", "--"] + +# development image +# docker build . --target=development +FROM node-tini as development ARG USER ENV USER ${USER:-node} ENV NODE_ENV=development @@ -51,9 +54,7 @@ COPY --from=builder --chown=node:node /opt/one-app/development ./ # production image # last so that it's the default image artifact -FROM node:$VERSION-alpine as production -# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals -RUN apk add --no-cache tini +FROM node-tini as production ARG USER ENV USER ${USER:-node} ENV NODE_ENV=production diff --git a/scripts/start.sh b/scripts/start.sh index 9045b7400..c83073c04 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -35,5 +35,5 @@ done commandArgs="$nodeArgs lib/server/index.js $flags" -echo "/sbin/tini -- node $commandArgs" -exec /sbin/tini -- node $commandArgs +echo "node $commandArgs" +exec node $commandArgs