Skip to content

Commit 031e010

Browse files
authored
Merge pull request #145 from MukeshAbhi/feature/docker
containerized the application
2 parents 86d5c88 + b511710 commit 031e010

9 files changed

Lines changed: 116 additions & 1 deletion

File tree

backend/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
dist
3+
build
4+
.DS_Store
5+
.env
6+
.env.local
7+
.env.development.local
8+
.env.test.local
9+
.env.production.local

backend/.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PORT=5000
2+
MONGO_URI=your-mongodb-atlas-uri
3+
JWT_SECRET=your-secret-key
4+
GEMINI_API_KEY=your-gemini-api-key
5+
KEEP_ALIVE_URL=http://localhost:5000

backend/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:18-alpine
2+
3+
WORKDIR /app
4+
5+
COPY package*.json ./
6+
7+
RUN npm install
8+
9+
COPY . .
10+
11+
EXPOSE 5000
12+
13+
CMD ["npm", "start"]

docker-compose.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: '3.8'
2+
3+
services:
4+
mongo:
5+
image: mongo
6+
container_name: paisable-mongo
7+
volumes:
8+
- mongo-data:/data/db
9+
networks:
10+
- app-network
11+
ports:
12+
- "27017:27017"
13+
14+
backend:
15+
build: ./backend
16+
container_name: backend
17+
ports:
18+
- "5000:5000"
19+
environment:
20+
- MONGO_URI=mongodb://mongo:27017/paisable
21+
env_file:
22+
- ./backend/.env
23+
depends_on:
24+
- mongo
25+
networks:
26+
- app-network
27+
28+
frontend:
29+
build: ./frontend
30+
container_name: frontend
31+
ports:
32+
- "5173:80"
33+
env_file:
34+
- ./frontend/.env
35+
depends_on:
36+
- backend
37+
networks:
38+
- app-network
39+
40+
networks:
41+
app-network:
42+
driver: bridge
43+
44+
volumes:
45+
mongo-data:

frontend/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
dist
3+
build
4+
.DS_Store
5+
.env
6+
.env.local
7+
.env.development.local
8+
.env.test.local
9+
.env.production.local

frontend/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_URL=http://localhost:5000/api

frontend/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ dist-ssr
2424
*.sln
2525
*.sw?
2626
.env
27-
.env.*
27+

frontend/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Stage 1 — Build the app
2+
FROM node:18-alpine AS builder
3+
4+
WORKDIR /app
5+
COPY package*.json ./
6+
RUN npm install
7+
COPY . .
8+
RUN npm run build
9+
10+
# Stage 2 — Serve with Nginx
11+
FROM nginx:alpine
12+
13+
COPY --from=builder /app/dist /usr/share/nginx/html
14+
COPY nginx.conf /etc/nginx/conf.d/default.conf
15+
16+
EXPOSE 80
17+
18+
CMD ["nginx", "-g", "daemon off;"]

frontend/nginx.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
location / {
9+
try_files $uri /index.html;
10+
}
11+
12+
# Logs
13+
access_log /var/log/nginx/access.log;
14+
error_log /var/log/nginx/error.log;
15+
}

0 commit comments

Comments
 (0)