From 72650d4dc3df8923cd0cd384aaf005457a8e0b89 Mon Sep 17 00:00:00 2001 From: Casper Date: Tue, 7 Jun 2022 11:54:58 +0200 Subject: [PATCH] Add basic container healthcheck (#2625) --- docker-compose.yml | 4 ++++ test/tests.bats | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 1e3e84ab..ee5f7a86 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,3 +26,7 @@ services: stop_grace_period: 1m cap_add: - NET_ADMIN + healthcheck: + test: "ss --listening --tcp | grep -P 'LISTEN.+:smtp' || exit 1" + timeout: 3s + retries: 0 diff --git a/test/tests.bats b/test/tests.bats index 460e6990..3c5c4e02 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -37,6 +37,7 @@ setup_file() { -e VIRUSMAILS_DELETE_DELAY=7 \ -h mail.my-domain.com \ --tty \ + --health-cmd "ss --listening --tcp | grep -P 'LISTEN.+:smtp' || exit 1" \ "${NAME}" wait_for_finished_setup_in_container mail @@ -1206,6 +1207,16 @@ EOF assert_failure } +# +# healthcheck +# + +@test "checking container healthcheck" { + run bash -c "docker inspect mail | jq -r '.[].State.Health.Status'" + assert_output "healthy" + assert_success +} + # # supervisor #