From 3580d9e5d309b7b7b59eea38c3a7d8e74cf183c2 Mon Sep 17 00:00:00 2001 From: mrrpnya Date: Wed, 5 Mar 2025 22:46:02 -0800 Subject: [PATCH] Updated Dockerfile to be faster and more secure --- Dockerfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index aec55c2..315d5a3 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,21 @@ # build stage FROM node:lts-alpine as build-stage WORKDIR /app -COPY package*.json ./ -RUN npm install +COPY package.json package-lock.json ./ +RUN npm ci --omit=dev COPY . . RUN npm run build # production stage FROM nginx:stable-alpine as production-stage + +# Remove default Nginx index page +RUN rm -rf /usr/share/nginx/html/* +# Copy built files from build stage COPY --from=build-stage /app/dist /usr/share/nginx/html EXPOSE 80 + +# Use a non-root user for security +USER nginx + CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file