diff --git a/Backend/dockerfile b/Backend/dockerfile new file mode 100644 index 0000000..93a3542 --- /dev/null +++ b/Backend/dockerfile @@ -0,0 +1,22 @@ +# Backend Dockerfile + +# Use the official Node.js image as a parent image +FROM node:14 + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install backend dependencies +RUN npm install + +# Copy the rest of the application code +COPY . . + +# Expose the port the app runs on (assuming default port 3000) +EXPOSE 3000 + +# Start the application +CMD ["npm", "start"] diff --git a/Backend/index.js b/Backend/index.js index a1474c2..090ce83 100644 --- a/Backend/index.js +++ b/Backend/index.js @@ -85,4 +85,4 @@ mongoose .then(() => console.log(`connected to db at port ${port} :)`)) .catch((err) => console.log(`${err} is error`)); -// updated with the ports +// updated with the ports \ No newline at end of file diff --git a/Frontend/dockerfile b/Frontend/dockerfile new file mode 100644 index 0000000..58628be --- /dev/null +++ b/Frontend/dockerfile @@ -0,0 +1,22 @@ +# Frontend Dockerfile + +# Use the official Node.js image as a parent image +FROM node:14 + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install frontend dependencies +RUN npm install + +# Copy the rest of the application code +COPY . . + +# Expose the port the app runs on +EXPOSE 5173 + +# Start the application +CMD ["npm", "run", "dev"] diff --git a/Frontend/vite.config.js b/Frontend/vite.config.js index 5a33944..0c65f76 100644 --- a/Frontend/vite.config.js +++ b/Frontend/vite.config.js @@ -4,4 +4,8 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + server: { + host: '0.0.0.0', + port: 5173 + } }) diff --git a/README.md b/README.md index cdfc9b6..6276eba 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,21 @@ The icons used in your instructions are relevant and intuitive for the steps des ```sh npm start ``` +

+### 🐬 Local Setup with Docker +If you have Docker installed, you can easily set up the application locally with the following steps: + +**Clone the Repository and navigate to the working directory** + +**Make sure you have docker installed on your system** +```bash +docker-compose up --build +``` +**After the Image is build You can access it on:-** +```bash +http://localhost:5173/ +``` You are all set! 🎉 ## 🔧 Creating a Pull Request diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1725270 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3' + +services: + frontend: + build: + context: ./frontend + ports: + - "5173:5173" + depends_on: + - backend + - mongodb + + backend: + build: + context: ./backend + ports: + - "4000:4000" + environment: + NODE_ENV: development + MONGO_URL: mongodb://mongodb:27017/ecommerce # MongoDB URI pointing to the MongoDB service + PORT: 4000 + STRIPE_SECRET_KEY: sk_test_51O96wfSH8i1UqUchc81vmn8Mka2bbbMrCW2vZKLEvGRTZDqWx2KlxkbLzdQnAJ0ipNA1UtO9Y83vX4x7KXjz5E4Z00JxrbAflY + depends_on: + - mongodb + + mongodb: + image: mongo:latest + ports: + - "27017:27017" + volumes: + - mongo-data:/data/db + +volumes: + mongo-data: