-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
211 lines (200 loc) · 4.96 KB
/
docker-compose.yml
File metadata and controls
211 lines (200 loc) · 4.96 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
services:
gateway_app:
build:
context: gateway/
container_name: gateway_app
env_file:
- ./gateway/.env.docker
ports:
- "${GATEWAY_PORT}:${GATEWAY_PORT}"
networks:
- appnet
entrypoint: ["sh", "-c"]
command:
- |
poetry run uvicorn main:app \
--host 0.0.0.0 \
--port ${GATEWAY_PORT}
depends_on:
loki:
condition: service_started
kafka:
condition: service_healthy
locust_gateway:
build:
context: gateway/
container_name: locust_gateway
env_file:
- ./gateway/.env.docker
ports:
- "8089:8089"
networks:
- appnet
entrypoint: ["sh", "-c"]
command:
- |
poetry run locust -f locustfile.py \
--host http://gateway_app:${GATEWAY_PORT}
depends_on:
gateway_app:
condition: service_started
tasks_app:
build:
context: tasks/
container_name: tasks_app
env_file:
- ./tasks/.env.docker
ports:
- "${TASKS_APP_PORT}"
entrypoint: ["sh", "-c"]
command:
- |
chmod +x /app/scripts/*.sh &&
/app/scripts/init_db.sh &&
poetry run uvicorn main:app \
--host 0.0.0.0 \
--port ${TASKS_APP_PORT}
depends_on:
db_tasks_app:
condition: service_healthy
loki:
condition: service_started
kafka:
condition: service_healthy
networks:
- appnet
tasks_app_worker:
build:
context: tasks/
container_name: tasks_app_worker
env_file:
- ./tasks/.env.docker
environment:
SERVICE_NAME: tasks_app
KAFKA_BOOTSTRAP: kafka:9092
KAFKA_GROUP_ID: tasks_app_group
entrypoint: ["sh", "-c"]
command:
- |
python worker.py
depends_on:
db_tasks_app:
condition: service_healthy
kafka:
condition: service_healthy
networks:
- appnet
deploy:
restart_policy:
condition: on-failure
db_tasks_app:
image: postgres:17
container_name: db_tasks_app
env_file:
- ./tasks/.env.docker
environment:
POSTGRES_USER: ${TASKS_DB_USER}
POSTGRES_PASSWORD: ${TASKS_DB_PASS}
POSTGRES_DB: ${TASKS_DB_NAME}
ports:
- "${TASKS_DB_PORT}"
volumes:
- db_tasks_app:/var/lib/postgresql/data
networks:
- appnet
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${TASKS_DB_USER}"]
interval: 5s
timeout: 5s
retries: 5
kafka:
image: bitnami/kafka:latest
container_name: kafka
# volumes:
# - kafka_data:/bitnami/kafka
environment:
KAFKA_BROKER_ID: 1
KAFKA_CFG_NODE_ID: 1
KAFKA_CFG_PROCESS_ROLES: "controller,broker"
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "1@kafka:9093"
KAFKA_CFG_LISTENERS: "CONTROLLER://:9093,PLAINTEXT://:9092"
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://kafka:9092"
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: "PLAINTEXT"
KAFKA_CFG_LOG_RETENTION_HOURS: "72" # 3 дня
ports:
- "9092:9092"
- "9093:9093"
healthcheck:
test: ["CMD", "bash", "-c", "kafka-topics.sh --list --bootstrap-server localhost:9092"]
interval: 10s
timeout: 5s
retries: 6
start_period: 20s
networks:
- appnet
kafka-ui:
image: provectuslabs/kafka-ui:latest
container_name: kafka-ui
ports:
- "8088:8080"
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
KAFKA_CLUSTERS_0_READONLY: "false"
depends_on:
kafka:
condition: service_healthy
networks:
- appnet
loki:
image: grafana/loki:latest
ports:
- "${LOKI_PORT}"
networks:
- appnet
volumes:
- ./loki-config.yaml:/etc/loki/local-config.yaml
- loki_data:/loki
command:
- -config.expand-env=true
- -config.file=/etc/loki/local-config.yaml
environment:
LOKI_PORT: ${LOKI_PORT}
promtail:
image: grafana/promtail:latest
networks:
- appnet
volumes:
- ./promtail-config.yaml:/etc/promtail/config.yaml
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/containers:/var/lib/docker/containers:ro
command:
- -config.expand-env=true
- -config.file=/etc/promtail/config.yaml
environment:
LOKI_URL: http://loki:${LOKI_PORT}/loki/api/v1/push
depends_on:
- loki
grafana:
image: grafana/grafana:latest
networks:
- appnet
ports:
- "${GRAFANA_PORT}:3000"
volumes:
- grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
networks:
appnet:
driver: bridge
volumes:
db_tasks_app:
loki_data:
grafana_data:
# kafka_data: