Skip to content

Commit

Permalink
Merge pull request #438 from vedantterse/dockerized-v
Browse files Browse the repository at this point in the history
dockerized the app
  • Loading branch information
harshalhonde21 authored Jun 29, 2024
2 parents 1a477b5 + ff5b993 commit 67d4e32
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Backend/dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion Backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 22 additions & 0 deletions Frontend/dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 4 additions & 0 deletions Frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,21 @@ The icons used in your instructions are relevant and intuitive for the steps des
```sh
npm start
```
<h2></h2>

### 🐬 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
Expand Down
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit 67d4e32

Please sign in to comment.