Skip to content

Commit 87860c1

Browse files
authored
Add docker (#18)
1 parent 7c41207 commit 87860c1

23 files changed

+458
-28
lines changed

backend/docker-compose.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
services:
2+
gateway-service:
3+
build:
4+
context: ./gateway-service
5+
container_name: gateway-service
6+
ports:
7+
- '4000:4000'
8+
volumes:
9+
- ./gateway-service:/app
10+
- /app/node_modules
11+
depends_on:
12+
- questions-service
13+
- users-service
14+
networks:
15+
- backend-network
16+
17+
questions-service:
18+
build:
19+
context: ./questions-service
20+
container_name: questions-service
21+
volumes:
22+
- ./questions-service:/app
23+
- /app/node_modules
24+
env_file:
25+
- ./questions-service/.env
26+
networks:
27+
- backend-network
28+
29+
users-service:
30+
build:
31+
context: ./users-service
32+
container_name: users-service
33+
volumes:
34+
- ./users-service:/app
35+
- /app/node_modules
36+
env_file:
37+
- ./users-service/.env
38+
networks:
39+
- backend-network
40+
41+
networks:
42+
backend-network:
43+
driver: bridge
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

backend/gateway-service/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 the base image
2+
FROM node:18-alpine
3+
4+
# Set the working directory in the container
5+
WORKDIR /app
6+
7+
# Copy the package.json and package-lock.json files
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code
14+
COPY . .
15+
16+
# Expose the port the app runs on
17+
EXPOSE 4000
18+
19+
# Start the application
20+
CMD ["npm", "start"]

backend/gateway-service/package-lock.json

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/gateway-service/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dependencies": {
2323
"@nestjs/common": "^10.0.0",
2424
"@nestjs/core": "^10.0.0",
25+
"@nestjs/microservices": "^10.4.1",
2526
"@nestjs/platform-express": "^10.0.0",
2627
"class-transformer": "^0.5.1",
2728
"class-validator": "^0.14.1",

backend/gateway-service/src/app.controller.spec.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

backend/gateway-service/src/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import { QuestionController } from './question/questions.controller';
1212
name: 'USER_SERVICE',
1313
transport: Transport.TCP,
1414
options: {
15-
host: '127.0.0.1',
15+
host: 'user-service',
1616
port: 3001,
1717
},
1818
},
1919
{
2020
name: 'QUESTION_SERVICE',
2121
transport: Transport.TCP,
2222
options: {
23-
host: '127.0.0.1',
23+
host: 'questions-service',
2424
port: 3002,
2525
},
2626
},

backend/gateway-service/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AppModule } from './app.module';
33

44
async function bootstrap() {
55
const app = await NestFactory.create(AppModule);
6-
await app.listen(3000);
7-
console.log('Gateway Service is listening on port 3000');
6+
await app.listen(4000);
7+
console.log('Gateway Service is listening on port 4000');
88
}
99
bootstrap();

backend/matching-service/package-lock.json

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/matching-service/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dependencies": {
2323
"@nestjs/common": "^10.0.0",
2424
"@nestjs/core": "^10.0.0",
25+
"@nestjs/microservices": "^10.4.1",
2526
"@nestjs/platform-express": "^10.0.0",
2627
"reflect-metadata": "^0.2.0",
2728
"rxjs": "^7.8.1"

0 commit comments

Comments
 (0)