forked from MNV/python-course-countries-informer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
144 lines (136 loc) · 4.08 KB
/
docker-compose.yaml
File metadata and controls
144 lines (136 loc) · 4.08 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
networks:
favorite-places:
services:
# основное приложение Django
countries-informer-app:
build: .
container_name: countries-informer-app
command: python manage.py runserver 0.0.0.0:8000
ports:
- "8020:8000"
volumes:
- ./src:/src
- ./docs:/docs
env_file:
- .env
depends_on:
countries-informer-db:
condition: service_healthy
restart: on-failure
networks:
- favorite-places
# СУБД PostgreSQL
countries-informer-db:
image: postgres:15-alpine
container_name: countries-informer-db
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ports:
- "54321:5432"
# https://docs.docker.com/compose/compose-file/compose-file-v3/#healthcheck
healthcheck:
# https://www.postgresql.org/docs/current/app-pg-isready.html
test: [ "CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'" ]
interval: 10s
timeout: 5s
retries: 5
restart: on-failure
networks:
- favorite-places
# СУБД Redis (кэширование и брокер сообщений для Celery)
countries-informer-redis:
image: redis:7-alpine
container_name: countries-informer-redis
environment:
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT}
- ALLOW_EMPTY_PASSWORD=yes
ports:
- "6379:6379"
restart: on-failure
networks:
- favorite-places
# сервис распределенной очереди задач Celery
countries-informer-celery:
build: .
container_name: countries-informer-celery
command: celery -A app worker --loglevel=info
volumes:
- ./src:/src
env_file:
- .env
depends_on:
countries-informer-redis:
condition: service_started
countries-informer-db:
condition: service_healthy
restart: on-failure
networks:
- favorite-places
# сервис для выполнения периодических заданий Celery Beat
countries-informer-celery-beat:
build: .
container_name: countries-informer-celery-beat
command: celery -A app beat -l info -S django --pidfile=/tmp/celerybeat.pid --schedule=/tmp/celerybeat-schedule
volumes:
- ./src:/src
env_file:
- .env
depends_on:
countries-informer-redis:
condition: service_started
countries-informer-db:
condition: service_healthy
countries-informer-celery:
condition: service_started
tmpfs: /tmp
restart: on-failure
networks:
- favorite-places
# мониторинг периодических задач Flower
countries-informer-flower:
image: mher/flower:0.9.7
container_name: countries-informer-flower
command: ["flower", "--broker=redis://countries-informer-redis:6379", "--port=5555"]
ports:
- "5555:5555"
depends_on:
countries-informer-redis:
condition: service_started
restart: on-failure
networks:
- favorite-places
# брокер сообщений RabbitMQ (коммуникации между микросервисами)
countries-informer-rabbitmq:
image: bitnami/rabbitmq:3.11.3
container_name: countries-informer-rabbitmq
ports:
- "5672:5672"
- "15672:15672"
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
- RABBITMQ_MANAGEMENT_SSL_VERIFY=verify_none
healthcheck:
test: rabbitmq-diagnostics -q check_virtual_hosts
interval: 10s
timeout: 5s
retries: 5
restart: always
networks:
- favorite-places
# очередь для приема сообщений
countries-informer-consumer:
build: .
container_name: countries-informer-consumer
command: python manage.py runconsumer ${RABBITMQ_QUEUE_PLACES_IMPORT}
env_file:
- .env
depends_on:
countries-informer-rabbitmq:
condition: service_healthy
restart: on-failure
networks:
- favorite-places