User non-root user for Dockerfile of nonrtric-controlpanel

Signed-off-by: ecaiyanlinux <martin.c.yan@est.tech>
Issue-ID: NONRTRIC-647
Change-Id: I60f83162c014643c6c980a466957f098a9103fd4
diff --git a/webapp-frontend/Dockerfile b/webapp-frontend/Dockerfile
index c4a07d2..c169935 100644
--- a/webapp-frontend/Dockerfile
+++ b/webapp-frontend/Dockerfile
@@ -33,4 +33,17 @@
 ### STAGE 2: Run App ###
 FROM nginx:alpine
 COPY nginx.conf /etc/nginx/nginx.conf
-COPY --from=stage1 /usr/src/app/dist/controlpanelApp /usr/share/nginx/html
\ No newline at end of file
+
+## use build-in nginx user
+ARG user=nginx
+
+## change ownership of nginx config files
+RUN chown -R $user /var/log/nginx
+RUN chown -R $user /etc/nginx/conf.d
+RUN chown -R $user /var/cache/nginx/
+RUN touch /var/run/nginx.pid
+RUN chown -R $user /var/run/nginx.pid
+
+USER ${user}
+
+COPY --chown=$user --from=stage1 /usr/src/app/dist/controlpanelApp /usr/share/nginx/html
\ No newline at end of file