Skip to content

Commit 12aef0a

Browse files
committed
Dockerise services and frontend
1 parent 3d6a9ac commit 12aef0a

File tree

10 files changed

+349
-10
lines changed

10 files changed

+349
-10
lines changed

ApiGatewayService/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use an official Node.js runtime as a parent image
2+
FROM node:14
3+
4+
# Set the working directory in the container
5+
WORKDIR /usr/src/api-gateway
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install app dependencies
11+
RUN npm install
12+
13+
# Bundle your app source code into the container
14+
COPY . .
15+
16+
# Expose the port on which your API gateway will run
17+
EXPOSE 3001
18+
19+
# Define the command to start your API gateway
20+
CMD [ "npm", "run", "dev"]

ApiGatewayService/package-lock.json

Lines changed: 168 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ApiGatewayService/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"express": "~4.16.1",
1616
"firebase": "^10.4.0",
1717
"http-errors": "~1.6.3",
18-
"http-proxy": "^1.18.1"
18+
"http-proxy": "^1.18.1",
19+
"socket.io": "^4.7.2"
1920
},
2021
"devDependencies": {
2122
"@types/express": "^4.17.18",

ApiGatewayService/src/index.ts

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,56 @@
11
import express from 'express';
22
import httpProxy from 'http-proxy';
33
import cors from 'cors';
4+
// import http from 'http';
5+
// import { Server } from 'socket.io';
46

57
const app = express();
68
const proxy = httpProxy.createProxyServer();
79
app.use(cors());
810

9-
// Define routes for each backend service
11+
// // Create an HTTP server and attach Socket.IO to it
12+
// const server = http.createServer(app);
13+
// const io = new Server(server, {
14+
// cors: {
15+
// origin: '*',
16+
// },
17+
// path: 'ws'
18+
// });
19+
20+
// Define routes for each backend service for local development
21+
// app.use('/questionservice', (req, res) => {
22+
// proxy.web(req, res, { target: 'http://localhost:3002' });
23+
// });
24+
25+
// app.use('/authservice', (req, res) => {
26+
// proxy.web(req, res, { target: 'http://localhost:3003' });
27+
// });
28+
29+
// app.use('/userservice', (req, res) => {
30+
// proxy.web(req, res, { target: 'http://localhost:3004' });
31+
// });
32+
33+
// app.use('/matchingservice', (req, res) => {
34+
// proxy.web(req, res, { target: 'http://localhost:3005' });
35+
// });
36+
37+
//Define routes for each backend service for production/docker containers
1038
app.use('/questionservice', (req, res) => {
11-
proxy.web(req, res, { target: 'http://localhost:3002' });
39+
proxy.web(req, res, { target: 'http://question-service:3002' });
1240
});
1341

1442
app.use('/authservice', (req, res) => {
15-
proxy.web(req, res, { target: 'http://localhost:3003' });
43+
proxy.web(req, res, { target: 'http://auth-service:3003' });
1644
});
1745

1846
app.use('/userservice', (req, res) => {
19-
proxy.web(req, res, { target: 'http://localhost:3004' });
47+
proxy.web(req, res, { target: 'http://user-service:3004' });
2048
});
2149

2250
app.use('/matchingservice', (req, res) => {
23-
proxy.web(req, res, { target: 'http://localhost:3005' });
51+
proxy.web(req, res, { target: 'http://matching-service:3005' });
2452
});
25-
2653
// Start the server
2754
app.listen(3001, () => {
2855
console.log('API Gateway listening on port 3001');
29-
});
56+
});

AuthService/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use an official Node.js runtime as a parent image
2+
FROM node:14
3+
4+
# Set the working directory in the container
5+
WORKDIR /usr/src/auth-service
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install app dependencies
11+
RUN npm install
12+
13+
# Bundle your app source code into the container
14+
COPY . .
15+
16+
# Expose the port on which your Auth service will run
17+
# EXPOSE 3003
18+
19+
# Define the command to start your Auth service
20+
CMD [ "npm", "run", "dev"]

MatchingService/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use an official Node.js runtime as a parent image
2+
FROM node:14
3+
4+
# Set the working directory in the container
5+
WORKDIR /usr/src/matching-service
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install app dependencies
11+
RUN npm install
12+
13+
# Bundle your app source code into the container
14+
COPY . .
15+
16+
# Expose the port on which your Auth service will run
17+
EXPOSE 3005
18+
19+
# Define the command to start your Auth service
20+
CMD [ "npm", "run", "dev"]

QuestionService/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use an official Node.js runtime as a parent image
2+
FROM node:14
3+
4+
# Set the working directory in the container
5+
WORKDIR /usr/src/question-service
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install app dependencies
11+
RUN npm install
12+
13+
# Bundle your app source code into the container
14+
COPY . .
15+
16+
# Expose the port on which your Auth service will run
17+
# EXPOSE 3002
18+
19+
# Define the command to start your Auth service
20+
CMD [ "npm", "run", "dev"]

0 commit comments

Comments
 (0)