From 99f243360a46277525ad7b6111809ce2b4a1064d Mon Sep 17 00:00:00 2001 From: Jeremy Ho Date: Wed, 8 Nov 2023 09:16:41 -0800 Subject: [PATCH] Fix NPM Cache directory permission and PID Signalling bugs NPM appears to not propagate the SIGTERM signal to the child node app on alpine. This is fixed by unwrapping the call and starting the app directly instead. NPM cache directory permission issues have appeared again for some external reason, so we need to mitigate by explicitly forcing a permission update on the cache directory to be owned by a non-root user. Signed-off-by: Jeremy Ho --- Dockerfile | 6 ++++-- app/Dockerfile | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 587ca86..8c07b7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,9 @@ RUN wget https://www2.gov.bc.ca/assets/gov/british-columbians-our-governments/se rm -rf ./BcSansFont_Print && \ fc-cache -f -# NPM Permission Fix (already present in base image) +# NPM Permission Fix +RUN mkdir -p /.npm +RUN chown -R 1001:0 /.npm # Install Application COPY app ${APP_ROOT} @@ -27,4 +29,4 @@ USER 1001 RUN npm ci --omit=dev EXPOSE ${APP_PORT} -CMD ["npm", "run", "start"] +CMD ["node", "./bin/www"] diff --git a/app/Dockerfile b/app/Dockerfile index ae78c78..c081c1e 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -18,7 +18,9 @@ RUN wget https://www2.gov.bc.ca/assets/gov/british-columbians-our-governments/se rm -rf ./BcSansFont_Print && \ fc-cache -f -# NPM Permission Fix (already present in base image) +# NPM Permission Fix +RUN mkdir -p /.npm +RUN chown -R 1001:0 /.npm # Install Application COPY . . @@ -27,4 +29,4 @@ USER 1001 RUN npm ci --omit=dev EXPOSE ${APP_PORT} -CMD ["npm", "run", "start"] +CMD ["node", "./bin/www"]