From 67d0919eb880534f4d93e4057cefd4d8659c6293 Mon Sep 17 00:00:00 2001 From: Suraj Date: Tue, 8 Oct 2024 20:00:47 +0530 Subject: [PATCH] feat: Optimize Dockerfile with Nginx. --- Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..71bed06d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Stage 1: Build the application +FROM node:18-alpine AS build + +# Setting up the working directory inside the container +WORKDIR /app + +# Copy package.json and package-lock.json to the working directory +COPY package.json package-lock.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application code to the working directory +COPY . . + +# Build the React application +RUN npm run build + +# Stage 2: Serve the application +FROM nginx:alpine + +# Copy built files from the previous stage +COPY --from=build /app/build /usr/share/nginx/html + +# Expose the port the app runs on +EXPOSE 80 + +# Start the Nginx server +CMD ["nginx", "-g", "daemon off;"]