-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathdocker-compose.full-demo.yml
153 lines (145 loc) · 4.2 KB
/
docker-compose.full-demo.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
145
146
147
148
149
150
151
152
153
# This Docker Compose file sets up the services
# and shared infrastructure on a common network called
# `mm_network`. Because of this, all services
# are able to communicate by using the value of their `container_name` key as the hostname.
# Only the ports for the `ingress`, `rabbitmq`, `notifier-db`, and `messenger-db` services are mapped to the host.
# For the `ingress` service, this is to make the backend services accessible.
# The other ports are exposed to the host for the purposes of accessing their
# GUI admin interfaces in the case of `rabbitmq`, and to allow the connection of
# database management tools in the case of the two postgres databases.
---
version: "3.9"
services:
ingress:
build: ./ingress
container_name: ingress
# The ingress service depends on the hostnames of the messenger application
# So it needs to start once those are created.
depends_on:
- messenger
- notifier
environment:
- NGINX_UPSTREAM=messenger
# The ingress service is the only service that has ports exposed out.
ports:
- 80:80
networks:
- mm_network
rabbitmq:
image: rabbitmq:3.11.4-management-alpine
container_name: rabbitmq
hostname: microservices_march
# The healthcheck is critical, because we need the RabbitMQ
# server to actually be up and accepting connections before we
# start the applications, otherwise they will crash.
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
timeout: 30s
retries: 3
ports:
- 5672:5672
- 15672:15672
volumes:
- rabbit-data:/var/lib/rabbitmq/
- rabbit-log:/var/log/rabbitmq/
networks:
- mm_network
messenger:
image: microservices_demo/messenger
container_name: messenger
# This uses the `Dockerfile` in the `messenger` repository
# to build the container for the service.
# If you've made changes to the `messenger` application,
# run `docker-compose -f docker-compose.full-demo.yml build`
# to make sure this file is using the updated container.
build:
context: ../messenger/app
depends_on:
rabbitmq:
condition: service_healthy
notifier-db:
condition: service_healthy
environment:
PGPASSWORD: postgres
CREATE_DB_NAME: messenger
PGHOST: messenger-db
PGPORT: 5432
AMQPHOST: rabbitmq
AMQPPORT: 5672
PORT: 4000
networks:
- mm_network
notifier:
image: microservices_demo/notifier
container_name: notifier
build:
context: ../notifier/app
depends_on:
rabbitmq:
condition: service_healthy
notifier-db:
condition: service_healthy
environment:
PGPASSWORD: postgres
CREATE_DB_NAME: notifier
PGHOST: notifier-db
# Note that we are running this database on a nonstandard port to avoid conflicts
PGPORT: 5433
AMQPHOST: rabbitmq
AMQPPORT: 5672
PORT: 5000
networks:
- mm_network
messenger-db:
image: postgres:15
container_name: messenger-db
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 30s
timeout: 30s
retries: 3
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: messenger
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- 5432:5432
volumes:
- messenger-db-data:/var/lib/postgresql/data/pgdata
networks:
- mm_network
notifier-db:
image: postgres:15
container_name: notifier-db
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 30s
timeout: 30s
retries: 3
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: notifier
PGDATA: /var/lib/postgresql/data/pgdata
PGPORT: 5433
ports:
- 5433:5433
volumes:
- notifier-db-data:/var/lib/postgresql/data/pgdata
networks:
- mm_network
# Docker volumes are used for all services
# that persist data to avoid permissions issues on some systems.
volumes:
rabbit-data:
rabbit-log:
messenger-db-data:
notifier-db-data:
networks:
mm_network:
name: mm_network
driver: bridge