-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
141 lines (130 loc) · 4.34 KB
/
docker-compose.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
version: "3.8"
services:
# default mysql database image
# this: &mysql-defaults allows us multiples databases
mysql-db-default: &mysql-defaults
image: mysql:latest
container_name: "mysql-db-default"
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- ./mysql:/var/lib/data
# instance of mysql database of ms-order
mysql-database-order:
<<: *mysql-defaults
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_ORDER_DATABASE}
- MYSQL_USER=${MYSQL_ORDER_DB_USER}
- MYSQL_PASSWORD=${MYSQL_ORDER_DB_PASSWORD}
ports:
- "3306:3306"
restart: always
container_name: "mysql-database-order"
healthcheck:
# ping the admin and marks the database container as healthy
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 20s
timeout: 5s
retries: 3
networks:
- compose-bridge
volumes:
- ./mysql-order:/var/lib/data
# instance of mysql database of ms-payments
mysql-database-payments:
<<: *mysql-defaults
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_PAYMENTS_DATABASE}
- MYSQL_USER=${MYSQL_PAYMENTS_DB_USER}
- MYSQL_PASSWORD=${MYSQL_PAYMENTS_DB_PASSWORD}
ports:
- "3307:3306"
restart: always
container_name: "mysql-database-payments"
healthcheck:
# ping the admin and marks the database container as healthy
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 20s
timeout: 5s
retries: 5
networks:
- compose-bridge
volumes:
- ./mysql-payments:/var/lib/data
service-discovery:
build:
context: ./service-discovery
dockerfile: ./Dockerfile
ports:
- "8761:8761"
container_name: "service-discovery"
volumes:
- ./data/service-discovery:/data
networks:
- compose-bridge
# obs: api-gateway in the beginning will fail because he will try to connect to Eureka Server, but it is OK
# because he will retry one more time after service-discovery already up
api-gateway:
build:
context: ./gateway
dockerfile: ./Dockerfile
ports:
- "8082:8082"
container_name: "api-gateway"
environment:
# IMPORTANT: To connect to Eureka server is necessary use container name (in this case service-discovery) instead
# localhost
- eureka.client.service-url.defaultZone=http://service-discovery:8761/eureka/
networks:
- compose-bridge
ms-order:
depends_on:
mysql-database-order:
condition: service_healthy
build:
context: ./ms-order
dockerfile: ./Dockerfile
environment:
# this will override argument when create the image
# In this case the url connection will be jdbc:mysql://mysql-database-order:3306/orders?createDatabaseIfNotExist=true
- MYSQL_ORDER_DB_INSTANCE=${MYSQL_ORDER_DB_INSTANCE}
- spring.datasource.username=${MYSQL_ORDER_DB_USER}
- spring.datasource.password=${MYSQL_ORDER_DB_PASSWORD}
# IMPORTANT: To connect to Eureka server is necessary use container name (in this case service-discovery) instead
# localhost
- eureka.client.service-url.defaultZone=http://service-discovery:8761/eureka/
container_name: "ms-order"
volumes:
- ./data/ms-order:/data
ports:
- "0"
networks:
- compose-bridge
ms-payments:
depends_on:
mysql-database-payments:
condition: service_healthy
build:
context: ./ms-payments
dockerfile: ./Dockerfile
environment:
# this will override argument when create the image
# In this case the url connection will be jdbc:mysql://mysql-database-order:3306/orders?createDatabaseIfNotExist=true
- MYSQL_PAYMENTS_DB_INSTANCE=${MYSQL_PAYMENTS_DB_INSTANCE}
- spring.datasource.username=${MYSQL_PAYMENTS_DB_USER}
- spring.datasource.password=${MYSQL_PAYMENTS_DB_PASSWORD}
# IMPORTANT: To connect to Eureka server is necessary use container name (in this case service-discovery) instead
# localhost
- eureka.client.service-url.defaultZone=http://service-discovery:8761/eureka/
container_name: "ms-payments"
volumes:
- ./data/ms-payments:/data
ports:
- "0"
networks:
- compose-bridge
networks:
compose-bridge:
driver: bridge