User non-root user for Dockerfile of nonrtric-controlpanel 23/7623/2
authorecaiyanlinux <martin.c.yan@est.tech>
Wed, 26 Jan 2022 12:44:54 +0000 (13:44 +0100)
committerecaiyanlinux <martin.c.yan@est.tech>
Fri, 28 Jan 2022 08:56:02 +0000 (09:56 +0100)
Signed-off-by: ecaiyanlinux <martin.c.yan@est.tech>
Issue-ID: NONRTRIC-647
Change-Id: I60f83162c014643c6c980a466957f098a9103fd4

webapp-frontend/Dockerfile

index c4a07d2..c169935 100644 (file)
@@ -33,4 +33,17 @@ RUN npm run-script build:prod
 ### 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