From 3abd64ae3ec657f83d017c6afde195981e802c7f Mon Sep 17 00:00:00 2001 From: Nischal2015 Date: Sun, 17 Dec 2023 16:58:11 +0545 Subject: [PATCH] Add nginx-unpriviliged dockerfile --- Dockerfile.nginx.prod | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Dockerfile.nginx.prod diff --git a/Dockerfile.nginx.prod b/Dockerfile.nginx.prod new file mode 100644 index 0000000..9e82edb --- /dev/null +++ b/Dockerfile.nginx.prod @@ -0,0 +1,36 @@ +FROM node:18.7.0-alpine3.15 as build + +WORKDIR /app + +RUN addgroup app && \ + adduser -S -G app app + +COPY ["package.json", "yarn.lock", "./"] + +RUN yarn + +COPY . . + +RUN yarn build + +# 2nd stage +FROM nginx:1.23.3-alpine-slim + +USER root + +RUN rm /etc/nginx/conf.d/default.conf && \ + rm /etc/nginx/nginx.conf && \ + chown -R nginx:nginx /var/cache/nginx && \ + chown -R nginx:nginx /var/run && \ + touch /var/run/nginx.pid && \ + chown -R nginx:nginx /var/run/nginx.pid + +COPY --from=build /app/dist /usr/share/nginx/html +COPY .nginx/nginx.conf /etc/nginx/nginx.conf +COPY .nginx/conf.d /etc/nginx/conf.d + +USER nginx + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file