From 645d8af22d5c144be6b3d4183b3da3648009715d Mon Sep 17 00:00:00 2001 From: thibaud-leclere Date: Tue, 5 May 2026 11:54:59 +0200 Subject: [PATCH] build: add service healthchecks --- compose.yaml | 15 ++++++++- tests/Docker/ComposeHealthcheckTest.php | 45 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/Docker/ComposeHealthcheckTest.php diff --git a/compose.yaml b/compose.yaml index 0356ee9..3ec9339 100644 --- a/compose.yaml +++ b/compose.yaml @@ -13,6 +13,12 @@ services: volumes: - app-data:/app/var/data - app-cache:/app/var/bootstrap-cache + healthcheck: + test: ["CMD-SHELL", "php -r 'exit(@fsockopen(\"127.0.0.1\", 9000) ? 0 : 1);'"] + interval: 10s + timeout: 3s + retries: 3 + start_period: 20s nginx: build: @@ -20,9 +26,16 @@ services: dockerfile: docker/Dockerfile target: web depends_on: - - app + app: + condition: service_healthy ports: - "${HTTP_PORT:-8080}:80" + healthcheck: + test: ["CMD-SHELL", "wget -q --spider http://127.0.0.1/ || exit 1"] + interval: 10s + timeout: 3s + retries: 3 + start_period: 20s volumes: app-data: diff --git a/tests/Docker/ComposeHealthcheckTest.php b/tests/Docker/ComposeHealthcheckTest.php new file mode 100644 index 0000000..651e776 --- /dev/null +++ b/tests/Docker/ComposeHealthcheckTest.php @@ -0,0 +1,45 @@ + ['condition' => 'service_healthy']], + $compose['services']['nginx']['depends_on'] ?? null + ); + } +}