Răsfoiți Sursa

Add docker-compose.healthcheck.yml

Ranger Chan 2 ani în urmă
părinte
comite
3a54f636cf

+ 2 - 2
compose/bin/docker-compose

@@ -7,7 +7,7 @@ else
 fi
 
 if [ "$1" == "--no-dev" ]; then
-  ${DOCKER_COMPOSE} -f docker-compose.yml "${@:2}"
+  ${DOCKER_COMPOSE} -f docker-compose.yml -f docker-compose.healthcheck.yml "${@:2}"
 else
-  ${DOCKER_COMPOSE} -f docker-compose.yml -f docker-compose.dev.yml "$@"
+  ${DOCKER_COMPOSE} -f docker-compose.yml -f docker-compose.healthcheck.yml -f docker-compose.dev.yml "$@"
 fi

+ 0 - 17
compose/bin/setup

@@ -29,23 +29,6 @@ bin/clinotty composer config --no-plugins allow-plugins.magento/magento-composer
 bin/clinotty composer config --no-plugins allow-plugins.magento/inventory-composer-installer true
 bin/clinotty composer config --no-plugins allow-plugins.laminas/laminas-dependency-plugin true
 
-echo "Waiting for connection to Elasticsearch..."
-bin/clinotty timeout $ES_HEALTHCHECK_TIMEOUT bash -c "
-    until curl --silent --output /dev/null http://$ES_HOST:$ES_PORT/_cat/health?h=st; do
-        printf '.'
-        sleep 2
-    done"
-[ $? != 0 ] && echo "Failed to connect to Elasticsearch" && exit
-
-echo ""
-echo "Waiting for connection to RabbitMQ..."
-bin/clinotty timeout $RABBITMQ_HEALTHCHECK_TIMEOUT bash -c "
-    until curl --silent --output /dev/null http://$RABBITMQ_DEFAULT_USER:$RABBITMQ_DEFAULT_PASS@$RABBITMQ_HOST:$RABBITMQ_MANAGEMENT_PORT/api/aliveness-test/%2F; do
-        printf '.'
-        sleep 2
-    done"
-[ $? != 0 ] && echo "Failed to connect to RabbitMQ" && exit
-
 bin/clinotty bin/magento setup:install \
   --db-host="$MYSQL_HOST" \
   --db-name="$MYSQL_DATABASE" \

+ 52 - 0
compose/docker-compose.healthcheck.yml

@@ -0,0 +1,52 @@
+version: "3"
+
+services:
+  app:
+    healthcheck:
+      test: 'curl --fail 127.0.0.1:8000'
+    depends_on:
+      phpfpm:
+        condition: service_started
+
+  phpfpm:
+    depends_on:
+      db:
+        condition: service_healthy
+      redis:
+        condition: service_healthy
+      elasticsearch:
+        condition: service_healthy
+      rabbitmq:
+        condition: service_healthy
+
+  db:
+    healthcheck:
+      test: 'mysqladmin ping -h localhost -u root -pmagento'
+      interval: 5s
+      timeout: 5s
+      retries: 30
+
+  redis:
+    healthcheck:
+      test: 'redis-cli ping || exit 1'
+      interval: 5s
+      timeout: 5s
+      retries: 30
+
+  elasticsearch:
+    healthcheck:
+      test: 'curl --fail elasticsearch:9200/_cat/health >/dev/null || exit 1'
+      interval: 5s
+      timeout: 5s
+      retries: 30
+
+  rabbitmq:
+    healthcheck:
+      test: 'rabbitmq-diagnostics -q ping'
+      interval: 5s
+      timeout: 5s
+      retries: 30
+
+  mailcatcher:
+    healthcheck:
+      test: 'wget --no-verbose --tries=1 --spider 127.0.0.1:1080 || exit 1'

+ 0 - 1
compose/env/elasticsearch.env

@@ -1,3 +1,2 @@
 ES_HOST=elasticsearch
 ES_PORT=9200
-ES_HEALTHCHECK_TIMEOUT=100

+ 0 - 1
compose/env/rabbitmq.env

@@ -4,4 +4,3 @@ RABBITMQ_MANAGEMENT_PORT=15672
 RABBITMQ_DEFAULT_USER=magento
 RABBITMQ_DEFAULT_PASS=magento
 RABBITMQ_DEFAULT_VHOST=/
-RABBITMQ_HEALTHCHECK_TIMEOUT=10