Skip to content

Commit

Permalink
Merge pull request #18 from rayyan35p/d3-containerize
Browse files Browse the repository at this point in the history
Add Docker files needed for containerization
  • Loading branch information
RingoftheKing authored Oct 2, 2024
2 parents ea5836c + bc6c614 commit b03ba5d
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions Backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
QuestionService/.env
user-service/.env
QuestionService/insert_questions_script.py

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
Expand Down
6 changes: 6 additions & 0 deletions Backend/QuestionService/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore node_modules to prevent large files being included
node_modules

# Ignore Docker-related files themselves
Dockerfile
.dockerignore
11 changes: 11 additions & 0 deletions Backend/QuestionService/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3001
CMD ["npm", "start"]
23 changes: 23 additions & 0 deletions Backend/QuestionService/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,27 @@ mongoose.connect(mongoURI)

app.use('/api/questions', questionRouter)

app.get("/", (req, res, next) => {
console.log("Sending Greetings!");
res.json({
message: "Hello World from question-service",
});
});

// Handle When No Route Match Is Found
app.use((req, res, next) => {
const error = new Error("Route Not Found");
error.status = 404;
next(error);
});

app.use((error, req, res, next) => {
res.status(error.status || 500);
res.json({
error: {
message: error.message,
},
});
});

module.exports = app
6 changes: 6 additions & 0 deletions Backend/user-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore node_modules to prevent large files being included
node_modules

# Ignore Docker-related files themselves
Dockerfile
.dockerignore
11 changes: 11 additions & 0 deletions Backend/user-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3002
CMD ["npm", "start"]
6 changes: 6 additions & 0 deletions Frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore node_modules to prevent large files being included
node_modules

# Ignore Docker-related files themselves
Dockerfile
.dockerignore
11 changes: 11 additions & 0 deletions Frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3000
CMD ["npm", "start"]
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
question-service:
build:
context: ./Backend/QuestionService
dockerfile: Dockerfile
ports:
- "3001:3001"

user-service:
build:
context: ./Backend/user-service
dockerfile: Dockerfile
ports:
- "3002:3002"

frontend:
build:
context: ./Frontend
dockerfile: Dockerfile
ports:
- "3000:3000"

0 comments on commit b03ba5d

Please sign in to comment.