From f0b8d61dadc28a0c8cb2fb4080c40460760c36b1 Mon Sep 17 00:00:00 2001 From: Saikiran121 <103639122+Saikiran121@users.noreply.github.com> Date: Fri, 24 Jan 2025 22:21:14 +0530 Subject: [PATCH] Added Dockerfile --- Dockerfile | 32 ++++++++++++++++++++++++++++++++ package.json | 6 +++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2d30c416 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Use the official Node.js image as the base image +FROM node:18 AS build + +# Set the working directory inside the container +WORKDIR /app + +# Copy package.json and package-lock.json (or yarn.lock) to the working directory +COPY package*.json ./ + +# Install the dependencies +RUN npm install + +# Copy the rest of the application code to the working directory +COPY . . + +# Build the React application +RUN npm run build + +# Use the official Nginx image as the base image for the production build +FROM nginx:alpine + +# Copy the built React application from the build stage to the Nginx HTML directory +COPY --from=build /app/build /usr/share/nginx/html + +# Copy custom Nginx configuration if needed +# COPY nginx.conf /etc/nginx/nginx.conf + +# Expose port 80 to the outside world +EXPOSE 80 + +# Start Nginx +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/package.json b/package.json index 3a51f600..55983b6e 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "react": "^16.13.1", "react-dom": "^16.13.1", "react-router-dom": "^5.1.2", - "react-scripts": "3.4.1" + "react-scripts": "^5.0.1" }, "scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d build", - "start": "react-scripts start", - "build": "react-scripts build", + "start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start", + "build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" },