From 13dca34c9a191073f420f1f7129e85793cbb2cee Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Thu, 24 Oct 2024 18:57:43 +0530 Subject: [PATCH] feat: client dockerfile --- Dockerfile.frontend | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile.frontend diff --git a/Dockerfile.frontend b/Dockerfile.frontend new file mode 100644 index 00000000..9fd668ad --- /dev/null +++ b/Dockerfile.frontend @@ -0,0 +1,29 @@ +# Use node image for the build stage +FROM node:18-alpine AS build + +# Set working directory in the container to /app +WORKDIR /app + +# Copy only the package.json and package-lock.json first for caching +COPY package.json package-lock.json ./ + +# Install dependencies (legacy peer deps is needed for react highlight, we get rid of it soon) +RUN npm install --legacy-peer-deps + +# Copy the entire project (including frontend code) +COPY . . + +# Build the frontend +RUN npm run build + +# Use NGINX for serving the built frontend in production +FROM nginx:stable-alpine + +# Copy the build output from the previous stage +COPY --from=build /app/build /usr/share/nginx/html + +# Expose the frontend port +EXPOSE 3000 + +# Start NGINX server +CMD ["nginx", "-g", "daemon off;"]