From 2b8fba9bee24c98cb7b170b70ba8dd8880195673 Mon Sep 17 00:00:00 2001 From: Akash-Nayak Date: Thu, 6 Apr 2023 21:09:58 +0530 Subject: [PATCH] fix: Resolve docker build failure of NodeJS application (#1017) Signed-off-by: Akash Nayak --- .../nodejs/templates/Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/built-in/transformers/dockerfilegenerator/nodejs/templates/Dockerfile b/assets/built-in/transformers/dockerfilegenerator/nodejs/templates/Dockerfile index e82af320d..d9fa4ee62 100644 --- a/assets/built-in/transformers/dockerfilegenerator/nodejs/templates/Dockerfile +++ b/assets/built-in/transformers/dockerfilegenerator/nodejs/templates/Dockerfile @@ -14,6 +14,13 @@ FROM registry.access.redhat.com/ubi8/nodejs-{{ .NodeMajorVersion }} COPY . . +{{- if eq .PackageManager "npm" }} +USER root +RUN mkdir -p /opt/app-root/src/.npm +RUN chown -R 1001:0 /opt/app-root/src/ +RUN chmod -R 775 /opt/app-root/src/ +USER 1001 +{{- end }} {{- if eq .PackageManager "yarn" }} RUN npm install --global yarn {{- end }} @@ -21,12 +28,5 @@ RUN {{ .PackageManager }} install {{- if .Build }} RUN {{ .PackageManager }} run build {{- end}} -{{- if eq .PackageManager "npm" }} -USER root -RUN mkdir -p /opt/app-root/src/.npm -RUN chown -R 1001:0 /opt/app-root/src/.npm -RUN chmod -R 775 /opt/app-root/src/.npm -USER 1001 -{{- end }} EXPOSE {{ .Port }} CMD {{ .PackageManager }} run start