-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
144 lines (143 loc) · 6.09 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
version: "3.8"
services:
workflows-service:
build:
context: .
dockerfile: ./Dockerfile
args:
- APP_NAME=workflows-service
command: npm run start:dev -- workflows-service # This instructs Docker Compose to run the "start:dev" script when starting the container
environment: # Here we specify the environment variables that will be passed to the container
- POSTGRES_HOST=workflows-db
- POSTGRES_PORT=5432
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=workflows
- RABBITMQ_URL=amqp://rabbitmq:5672
deploy:
replicas: 3 # This instructs Docker Compose to start 3 instances of the "workflows-service" container
volumes:
- ./libs:/usr/src/app/libs
- ./package.json:/usr/src/app/package.json
- ./tsconfig.json:/usr/src/app/tsconfig.json
# Note: This is usually not a good practice to mount the "node_modules" directory on the host to the container # We are doing this for the sake of simplicity in this example - ./node_modules:/usr/src/app/node_modules
# This instructs Docker Compose to mount the "workflows-service" directory on the host to the "/usr/src/app" directory on the container
# This allows us to make changes to the code on the host and have them reflected in the container without having to rebuild the image
- ./apps/workflows-service:/usr/src/app/apps/workflows-service
depends_on: # This instructs Docker Compose to start the "workflows-db" container before starting the "workflows-service" container
- workflows-db
- nats
- rabbitmq
workflows-db:
image: postgres:13.2-alpine
environment: # We need to make sure these environment variables match the ones we specified in the "workflows-service" service
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=workflows
virtual-facility:
build:
context: .
dockerfile: ./Dockerfile
args:
- APP_NAME=virtual-facility
command: npm run start:dev -- virtual-facility
ports:
- 3000:3000 # This instructs Docker Compose to map port 3000 on the host to port 3000 on the container
environment:
- POSTGRES_HOST=virtual-facility-db
- POSTGRES_PORT=5432
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=virtual-facility
- RABBITMQ_URL=amqp://rabbitmq:5672
volumes:
- ./libs:/usr/src/app/libs
- ./package.json:/usr/src/app/package.json
- ./tsconfig.json:/usr/src/app/tsconfig.json
# Note: This is usually not a good practice to mount the "node_modules" directory on the host to the container # We are doing this for the sake of simplicity in this example - ./node_modules:/usr/src/app/node_modules
- ./apps/virtual-facility:/usr/src/app/apps/virtual-facility
depends_on:
- virtual-facility-db
- workflows-service
- nats
- rabbitmq
virtual-facility-db:
image: postgres:13.2-alpine
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=virtual-facility
nats:
image: nats:2.2.2-alpine
alarms-service:
build:
context: .
dockerfile: ./Dockerfile
args:
- APP_NAME=alarms-service
command: npm run start:dev -- alarms-service
environment:
- NATS_URL=nats://nats:4222
- RABBITMQ_URL=amqp://rabbitmq:5672
volumes:
- ./libs:/usr/src/app/libs
- ./package.json:/usr/src/app/package.json
- ./tsconfig.json:/usr/src/app/tsconfig.json
# Note: This is usually not a good practice to mount the "node_modules" directory on the host to the container # We are doing this for the sake of simplicity in this example - ./node_modules:/usr/src/app/node_modules
- ./apps/alarms-service:/usr/src/app/apps/alarms-service
depends_on:
- nats
- rabbitmq
alarms-generator:
build:
context: .
dockerfile: ./Dockerfile
args:
- APP_NAME=alarms-generator
command: npm run start:dev -- alarms-generator
environment:
- NATS_URL=nats://nats:4222
volumes:
- ./libs:/usr/src/app/libs
- ./package.json:/usr/src/app/package.json
- ./tsconfig.json:/usr/src/app/tsconfig.json
# Note: This is usually not a good practice to mount the "node_modules" directory on the host to the container # We are doing this for the sake of simplicity in this example - ./node_modules:/usr/src/app/node_modules
- ./apps/alarms-generator:/usr/src/app/apps/alarms-generator
depends_on:
- nats
alarms-classifier-service:
build:
context: .
dockerfile: ./Dockerfile
args:
- APP_NAME=alarms-classifier-service
command: npm run start:dev -- alarms-classifier-service
environment:
- NATS_URL=nats://nats:4222
volumes:
- ./libs:/usr/src/app/libs
- ./package.json:/usr/src/app/package.json
- ./tsconfig.json:/usr/src/app/tsconfig.json
# Note: This is usually not a good practice to mount the "node_modules" directory on the host to the container # We are doing this for the sake of simplicity in this example - ./node_modules:/usr/src/app/node_modules
- ./apps/alarms-classifier-service:/usr/src/app/apps/alarms-classifier-service
depends_on:
- nats
notifications-service:
build:
context: .
dockerfile: ./Dockerfile
args:
- APP_NAME=notifications-service
command: npm run start:dev -- notifications-service
environment:
- RABBITMQ_URL=amqp://rabbitmq:5672
volumes:
- ./libs:/usr/src/app/libs
- ./package.json:/usr/src/app/package.json
- ./tsconfig.json:/usr/src/app/tsconfig.json
# Note: This is usually not a good practice to mount the "node_modules" directory on the host to the container # We are doing this for the sake of simplicity in this example - ./node_modules:/usr/src/app/node_modules
- ./apps/notifications-service:/usr/src/app/apps/notifications-service
depends_on:
- rabbitmq
rabbitmq:
image: rabbitmq:3.8.14-management-alpine