From 3cbf87f0477822d3a9e5d553037f0aff364b7eb0 Mon Sep 17 00:00:00 2001 From: Akash Nayak Date: Thu, 6 Apr 2023 17:22:16 +0530 Subject: [PATCH] fix: Resolve docker build failure of NodeJS application 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