-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
124 lines (118 loc) · 3.02 KB
/
Copy pathdocker-compose.yml
File metadata and controls
124 lines (118 loc) · 3.02 KB
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
services:
mongo:
image: mongo:7
command:
- --replSet
- rs0
- --bind_ip_all
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
healthcheck:
test: ["CMD-SHELL", "mongosh --quiet --eval 'db.runCommand({ ping: 1 }).ok' || exit 1"]
interval: 5s
timeout: 5s
retries: 30
mongo-init:
image: mongo:7
depends_on:
mongo:
condition: service_healthy
volumes:
- ./validation.js:/scripts/validation.js:ro
- ./data.js:/scripts/data.js:ro
entrypoint:
- /bin/bash
- -lc
- |
set -euo pipefail
until mongosh --host mongo:27017 --quiet --eval 'db.runCommand({ ping: 1 }).ok' >/dev/null; do
sleep 2
done
mongosh --host mongo:27017 --quiet --eval 'try { rs.status().ok } catch (e) { rs.initiate({_id:"rs0",members:[{_id:0,host:"mongo:27017"}]}) }'
until mongosh --host mongo:27017 --quiet --eval 'db.hello().isWritablePrimary' | grep true >/dev/null; do
sleep 2
done
mongosh 'mongodb://mongo:27017/car_rental?replicaSet=rs0' --file /scripts/validation.js
mongosh 'mongodb://mongo:27017/car_rental?replicaSet=rs0' --file /scripts/data.js
restart: "no"
api:
build:
context: .
dockerfile: Dockerfile
depends_on:
mongo-init:
condition: service_completed_successfully
environment:
DATA_BACKEND: mongo
MONGO_URL: mongodb://mongo:27017/?replicaSet=rs0
MONGO_DB_NAME: car_rental
ports:
- "8080:8080"
command:
- --host
- 0.0.0.0
- --port
- "8080"
- --data-backend
- mongo
- --mongo-url
- mongodb://mongo:27017/?replicaSet=rs0
- --mongo-db
- car_rental
- --jwt-secret
- docker-dev-secret
- --manager-password
- Manager123!
rabbitmq:
image: rabbitmq:3.13-management
profiles:
- lab06
ports:
- "5672:5672"
- "15672:15672"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 5s
timeout: 5s
retries: 30
lab06-producer:
profiles:
- lab06
build:
context: ./labs/lab06/event_service
dockerfile: Dockerfile
depends_on:
mongo-init:
condition: service_completed_successfully
rabbitmq:
condition: service_healthy
environment:
MONGO_URL: mongodb://mongo:27017/?replicaSet=rs0
MONGO_DB_NAME: car_rental
RABBITMQ_URL: amqp://guest:guest@rabbitmq:5672/%2F
command:
- python
- producer.py
restart: "no"
lab06-consumer:
profiles:
- lab06
build:
context: ./labs/lab06/event_service
dockerfile: Dockerfile
depends_on:
rabbitmq:
condition: service_healthy
environment:
RABBITMQ_URL: amqp://guest:guest@rabbitmq:5672/%2F
CQRS_STATE_PATH: /state/read_model.json
volumes:
- lab06_consumer_state:/state
command:
- python
- consumer.py
volumes:
mongo_data:
lab06_consumer_state: