From 108b4b107ad883ce6c8aebadabbf037ac7b577aa 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 27a879409..8e81154a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,9 @@ RUN NODE_ENV=production npm run build && \ # development image # docker build . --target=development FROM node:18.20.1-alpine as development +# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals +RUN apk add --no-cache tini +ENTRYPOINT ["/sbin/tini", "--"] ARG USER ENV USER ${USER:-node} ENV NODE_ENV=development @@ -48,6 +51,9 @@ COPY --from=builder --chown=node:node /opt/one-app/development ./ # production image # last so that it's the default image artifact FROM node:18.20.1-alpine as production +# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals +RUN apk add --no-cache tini +ENTRYPOINT ["/sbin/tini", "--"] ARG USER ENV USER ${USER:-node} ENV NODE_ENV=production From db7e489e57481623aa4a2dc078dc0336be20fc8f Mon Sep 17 00:00:00 2001 From: Nick Oliver Date: Tue, 16 Apr 2024 10:47:06 -0700 Subject: [PATCH 2/2] refactor(image): common layer for installing tini --- Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e81154a7..249c02972 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,12 +27,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:18.20.1-alpine as development # https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals +FROM node:18.20.1-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 @@ -50,10 +52,7 @@ COPY --from=builder --chown=node:node /opt/one-app/development ./ # production image # last so that it's the default image artifact -FROM node:18.20.1-alpine as production -# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals -RUN apk add --no-cache tini -ENTRYPOINT ["/sbin/tini", "--"] +FROM node-tini as production ARG USER ENV USER ${USER:-node} ENV NODE_ENV=production