Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions amazon-backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MONGO_URI=mongodb://mongo:27017/amazonclone
PAYPAL_CLIENT_ID=your_paypal_client_id
PORT=5000
11 changes: 11 additions & 0 deletions amazon-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 5000
CMD ["npm", "start"]
4 changes: 3 additions & 1 deletion amazon-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"express-async-handler": "^1.1.4",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.11.9",
"nodemon": "^2.0.6"
"nodemon": "^2.0.6",
"postcss": "8.4.31",
"postcss-safe-parser": "6.0.0"
},
"engines": {
"node": "16.x"
Expand Down
2 changes: 1 addition & 1 deletion amazon-backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dotenv.config();

const app = express()
const port = process.env.PORT || 5000;
const connection_url = process.env.MONGO_URL;
const connection_url = process.env.MONGO_URI;

mongoose.connect(connection_url,{
useCreateIndex: true,
Expand Down
11 changes: 11 additions & 0 deletions amazon-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3000
CMD ["npm", "start"]
4 changes: 3 additions & 1 deletion amazon-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"slick-carousel": "^1.8.1",
"web-vitals": "^0.2.4"
"web-vitals": "^0.2.4",
"postcss": "8.4.31",
"postcss-safe-parser": "6.0.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion amazon-frontend/src/Axios.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios'

const instance = axios.create({
baseURL: "https://amazon-be-7evd.onrender.com"
baseURL: "http://localhost:5000"
})

export default instance
3 changes: 2 additions & 1 deletion amazon-frontend/src/actions/ProdcutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const listProducts = () => async (dispatch) =>{

try{
const {data} = await axios.get("/api/products");
console.log("Products : ", data)
const count = data.length;
dispatch({
type: PRODUCT_LIST_SUCCESS,
Expand Down Expand Up @@ -54,4 +55,4 @@ export const detailsProduct = (productID) => async (dispatch) =>{
: error.message,
});
}
};
};
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
backend:
build: ./amazon-backend
ports:
- "5000:5000"
env_file:
- ./amazon-backend/.env
depends_on:
- mongo

frontend:
build: ./amazon-frontend
ports:
- "3000:3000"
depends_on:
- backend

mongo:
image: mongo:6
restart: always
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db

volumes:
mongo-data: