@@ -4,9 +4,11 @@ services:
44 context : gateway/
55 container_name : gateway_app
66 env_file :
7- - ./gateway/.env
7+ - ./gateway/.env.docker
88 ports :
99 - " ${GATEWAY_PORT}:${GATEWAY_PORT}"
10+ networks :
11+ - appnet
1012 entrypoint : ["sh", "-c"]
1113 command :
1214 - |
@@ -16,13 +18,34 @@ services:
1618 depends_on :
1719 loki :
1820 condition : service_started
21+ kafka :
22+ condition : service_healthy
23+
24+ locust_gateway :
25+ build :
26+ context : gateway/
27+ container_name : locust_gateway
28+ env_file :
29+ - ./gateway/.env.docker
30+ ports :
31+ - " 8089:8089"
32+ networks :
33+ - appnet
34+ entrypoint : ["sh", "-c"]
35+ command :
36+ - |
37+ poetry run locust -f locustfile.py \
38+ --host http://gateway_app:${GATEWAY_PORT}
39+ depends_on :
40+ gateway_app :
41+ condition : service_started
1942
2043 tasks_app :
2144 build :
2245 context : tasks/
2346 container_name : tasks_app
2447 env_file :
25- - ./tasks/.env
48+ - ./tasks/.env.docker
2649 ports :
2750 - " ${TASKS_APP_PORT}"
2851 entrypoint : ["sh", "-c"]
@@ -38,12 +61,41 @@ services:
3861 condition : service_healthy
3962 loki :
4063 condition : service_started
64+ kafka :
65+ condition : service_healthy
66+ networks :
67+ - appnet
68+
69+ tasks_app_worker :
70+ build :
71+ context : tasks/
72+ container_name : tasks_app_worker
73+ env_file :
74+ - ./tasks/.env.docker
75+ environment :
76+ SERVICE_NAME : tasks_app
77+ KAFKA_BOOTSTRAP : kafka:9092
78+ KAFKA_GROUP_ID : tasks_app_group
79+ entrypoint : ["sh", "-c"]
80+ command :
81+ - |
82+ python worker.py
83+ depends_on :
84+ db_tasks_app :
85+ condition : service_healthy
86+ kafka :
87+ condition : service_healthy
88+ networks :
89+ - appnet
90+ deploy :
91+ restart_policy :
92+ condition : on-failure
4193
4294 db_tasks_app :
4395 image : postgres:17
4496 container_name : db_tasks_app
4597 env_file :
46- - ./tasks/.env
98+ - ./tasks/.env.docker
4799 environment :
48100 POSTGRES_USER : ${TASKS_DB_USER}
49101 POSTGRES_PASSWORD : ${TASKS_DB_PASS}
@@ -52,16 +104,64 @@ services:
52104 - " ${TASKS_DB_PORT}"
53105 volumes :
54106 - db_tasks_app:/var/lib/postgresql/data
107+ networks :
108+ - appnet
55109 healthcheck :
56110 test : ["CMD-SHELL", "pg_isready -U ${TASKS_DB_USER}"]
57111 interval : 5s
58112 timeout : 5s
59113 retries : 5
60-
114+
115+ kafka :
116+ image : bitnami/kafka:latest
117+ container_name : kafka
118+ # volumes:
119+ # - kafka_data:/bitnami/kafka
120+ environment :
121+ KAFKA_BROKER_ID : 1
122+ KAFKA_CFG_NODE_ID : 1
123+ KAFKA_CFG_PROCESS_ROLES : " controller,broker"
124+ KAFKA_CFG_CONTROLLER_QUORUM_VOTERS : " 1@kafka:9093"
125+ KAFKA_CFG_LISTENERS : " CONTROLLER://:9093,PLAINTEXT://:9092"
126+ KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP : " CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
127+ KAFKA_CFG_ADVERTISED_LISTENERS : " PLAINTEXT://kafka:9092"
128+ KAFKA_CFG_CONTROLLER_LISTENER_NAMES : " CONTROLLER"
129+ KAFKA_AUTO_CREATE_TOPICS_ENABLE : " true"
130+ KAFKA_CFG_INTER_BROKER_LISTENER_NAME : " PLAINTEXT"
131+ KAFKA_CFG_LOG_RETENTION_HOURS : " 72" # 3 дня
132+ ports :
133+ - " 9092:9092"
134+ - " 9093:9093"
135+ healthcheck :
136+ test : ["CMD", "bash", "-c", "kafka-topics.sh --list --bootstrap-server localhost:9092"]
137+ interval : 10s
138+ timeout : 5s
139+ retries : 6
140+ start_period : 20s
141+ networks :
142+ - appnet
143+
144+ kafka-ui :
145+ image : provectuslabs/kafka-ui:latest
146+ container_name : kafka-ui
147+ ports :
148+ - " 8088:8080"
149+ environment :
150+ KAFKA_CLUSTERS_0_NAME : local
151+ KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS : kafka:9092
152+ KAFKA_CLUSTERS_0_READONLY : " false"
153+ depends_on :
154+ kafka :
155+ condition : service_healthy
156+ networks :
157+ - appnet
158+
61159 loki :
62160 image : grafana/loki:latest
63161 ports :
64162 - " ${LOKI_PORT}"
163+ networks :
164+ - appnet
65165 volumes :
66166 - ./loki-config.yaml:/etc/loki/local-config.yaml
67167 - loki_data:/loki
@@ -73,6 +173,8 @@ services:
73173
74174 promtail :
75175 image : grafana/promtail:latest
176+ networks :
177+ - appnet
76178 volumes :
77179 - ./promtail-config.yaml:/etc/promtail/config.yaml
78180 - /var/run/docker.sock:/var/run/docker.sock
@@ -87,6 +189,8 @@ services:
87189
88190 grafana :
89191 image : grafana/grafana:latest
192+ networks :
193+ - appnet
90194 ports :
91195 - " ${GRAFANA_PORT}:3000"
92196 volumes :
@@ -96,7 +200,12 @@ services:
96200 - GF_SECURITY_ADMIN_PASSWORD=admin
97201 - GF_USERS_ALLOW_SIGN_UP=false
98202
203+ networks :
204+ appnet :
205+ driver : bridge
206+
99207volumes :
100208 db_tasks_app :
101209 loki_data :
102210 grafana_data :
211+ # kafka_data:
0 commit comments