Bladeren bron

comit services healthcheck

placidenduwayo 1 jaar geleden
bovenliggende
commit
05a49578eb
1 gewijzigde bestanden met toevoegingen van 34 en 27 verwijderingen
  1. 34
    27
      docker-compose.yml

+ 34
- 27
docker-compose.yml Bestand weergeven

@@ -7,24 +7,35 @@ services:
7 7
     container_name: microservices-db
8 8
     restart: always
9 9
     ports:
10
-      - "3306:3306"
10
+      - 3306:3306
11 11
     networks:
12 12
       - microservices-network
13 13
     environment:
14 14
       MYSQL_ROOT_PASSWORD: pwd
15 15
     volumes:
16 16
       - services-db:/var/lib/mysql
17
+    healthcheck:
18
+      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot", "-ppwd"]
19
+      interval: 5s
20
+      timeout: 5s
21
+      retries: 20
17 22
     
18 23
   microservices-config-service:
19 24
     image: microservices-config-service:latest
20 25
     container_name: microservices-config-service
21 26
     ports:
22
-      - "8280:8280"
27
+      - 8280:8280
23 28
     networks:
24 29
       - microservices-network
25 30
     build: 
26 31
       context: ../backend-frontend-app/spring-project-back/microservices-config-service
27 32
       dockerfile: Dockerfile
33
+    healthcheck:
34
+      test: ["CMD", "curl", "-I", "http://microservices-config-service:8280"]
35
+      interval: 15s
36
+      timeout: 10s
37
+      retries: 3
38
+      start_period: 40s
28 39
   
29 40
   microservices-registration-service:
30 41
     image: microservices-registration-service:latest
@@ -33,12 +44,18 @@ services:
33 44
       context: ../backend-frontend-app/spring-project-back/microservices-registration-service
34 45
       dockerfile: Dockerfile
35 46
     ports:
36
-      - "8761:8761"
47
+      - 8761:8761
37 48
     networks:
38 49
       - microservices-network
39 50
     depends_on:
40 51
       microservices-config-service:
41
-       condition: service_completed_successfully
52
+        condition: service_healthy
53
+    healthcheck:
54
+      test: ["CMD", "curl", "-I", "http://microservices-registration-service:8761"]
55
+      interval: 30s
56
+      timeout: 30s
57
+      retries: 3
58
+      start_period: 40s
42 59
 
43 60
   backend-frontend-gateway-service:
44 61
     image: backend-frontend-gateway-service:latest
@@ -49,10 +66,8 @@ services:
49 66
       context: ../backend-frontend-app/spring-project-back/backend-frontend-gateway-service
50 67
       dockerfile: Dockerfile
51 68
     depends_on:
52
-      microservices-config-service:
53
-        condition: service_completed_successfully
54 69
       microservices-registration-service:
55
-        condition: service_completed_successfully
70
+        condition: service_healthy
56 71
     networks:
57 72
       - microservices-network
58 73
 
@@ -63,14 +78,12 @@ services:
63 78
       context: ..//backend-frontend-app/spring-project-back/clean-archi-business-service-address
64 79
       dockerfile: Dockerfile
65 80
     ports:
66
-      - "8282:8282"
81
+      - 8282:8282
67 82
     depends_on:
68 83
       microservices-db:
69
-        condition: service_completed_successfully
70
-      microservices-config-service:
71
-        condition: service_completed_successfully
84
+        condition: service_healthy
72 85
       microservices-registration-service:
73
-        condition: service_completed_successfully
86
+        condition: service_healthy
74 87
     networks:
75 88
       - microservices-network
76 89
     
@@ -81,14 +94,12 @@ services:
81 94
       context: ../backend-frontend-app/spring-project-back/clean-archi-business-service-company
82 95
       dockerfile: Dockerfile
83 96
     ports:
84
-      - "8284:8284"
97
+      - 8284:8284
85 98
     depends_on:
86 99
       microservices-db:
87
-        condition: service_completed_successfully
88
-      microservices-config-service:
89
-        condition: service_completed_successfully
100
+        condition: service_healthy
90 101
       microservices-registration-service:
91
-        condition: service_completed_successfully
102
+        condition: service_healthy
92 103
     networks:
93 104
       - microservices-network
94 105
   
@@ -99,14 +110,12 @@ services:
99 110
       context: ../backend-frontend-app/spring-project-back/clean-archi-business-service-employee
100 111
       dockerfile: Dockerfile
101 112
     ports:
102
-      - "8283:8283"
113
+      - 8283:8283
103 114
     depends_on:
104 115
       microservices-db:
105
-        condition: service_completed_successfully
106
-      microservices-config-service:
107
-        condition: service_completed_successfully
116
+        condition: service_healthy
108 117
       microservices-registration-service:
109
-        condition: service_completed_successfully
118
+        condition: service_healthy
110 119
     networks:
111 120
       - microservices-network
112 121
   
@@ -117,14 +126,12 @@ services:
117 126
       context: ../backend-frontend-app/spring-project-back/clean-archi-business-service-project
118 127
       dockerfile: Dockerfile
119 128
     ports:
120
-      - "8285:8285"
129
+      - 8285:8285
121 130
     depends_on:
122 131
       microservices-db:
123
-        condition: service_completed_successfully
124
-      microservices-config-service:
125
-        condition: service_completed_successfully
132
+        condition: service_healthy
126 133
       microservices-registration-service:
127
-        condition: service_completed_successfully
134
+        condition: service_healthy
128 135
     networks:
129 136
       - microservices-network
130 137
 

Powered by TurnKey Linux.