From 43ac877c7d18f2573459fb949e84f5b1862650c2 Mon Sep 17 00:00:00 2001 From: Sheersh Date: Tue, 26 Dec 2023 07:24:04 +0530 Subject: [PATCH 1/2] chore(docker): Modified the Dockerfile --- Dockerfile | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f396314..e6021e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,30 @@ # EXPOSE 80 # CMD ["nginx", "-g", "daemon off;"] -FROM node:16-slim +# FROM node:16-slim +# WORKDIR /app +# COPY build/ ./build/ +# EXPOSE 80 +# RUN npm install -g serve +# CMD ["serve", "-s", "build", "-p", "80"] + +FROM node:16-slim as builder + WORKDIR /app -COPY build/ ./build/ -EXPOSE 80 -RUN npm install -g serve -CMD ["serve", "-s", "build", "-p", "80"] +COPY package*.json ./ + +RUN npm install -g + +COPY . . + +RUN npm ci --force +RUN npm run build + +FROM nginx:stable-alpine + +COPY --from=builder /app /usr/share/nginx/html + +EXPOSE 81 + +CMD ["nginx", "-g", "daemon off;"] From 344dbd62cb29ddf1178bcf0123cc34dce7d508fe Mon Sep 17 00:00:00 2001 From: Sheersh Date: Wed, 27 Dec 2023 14:46:33 +0530 Subject: [PATCH 2/2] chore(docker): used slim images in the Dockerfile --- Dockerfile | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index e6021e5..421f909 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,42 +1,16 @@ -# Builder already added via Github Actions -# Uncomment for full workflow action -# FROM node:slim as build-stage -# ENV NODE_OPTIONS=--openssl-legacy-provider -# WORKDIR /app -# COPY package.json ./ -# COPY package-lock.json ./ -# COPY . . -# RUN npm ci --force -# RUN npm run build -# FROM nginx:stable-alpine -# COPY --from=build-stage /app/build/ /usr/share/nginx/html -# EXPOSE 80 -# CMD ["nginx", "-g", "daemon off;"] - -# FROM node:16-slim -# WORKDIR /app -# COPY build/ ./build/ -# EXPOSE 80 -# RUN npm install -g serve -# CMD ["serve", "-s", "build", "-p", "80"] - FROM node:16-slim as builder WORKDIR /app -COPY package*.json ./ - -RUN npm install -g - COPY . . RUN npm ci --force RUN npm run build -FROM nginx:stable-alpine +FROM nginx:alpine-slim -COPY --from=builder /app /usr/share/nginx/html +COPY --from=builder /app/build/ /usr/share/nginx/html -EXPOSE 81 +EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]