diff --git a/deploy/portainer/docker-compose.yml b/deploy/portainer/docker-compose.yml index 1611d38c..bb5d2575 100644 --- a/deploy/portainer/docker-compose.yml +++ b/deploy/portainer/docker-compose.yml @@ -45,6 +45,12 @@ x-redis-session-env: &redis-session-env REDIS_USERNAME: ${REDIS_USERNAME:-} REDIS_PASSWORD: ${REDIS_PASSWORD:-} +x-readiness-healthcheck: &readiness-healthcheck + interval: 30s + timeout: 5s + retries: 3 + start_period: 60s + services: gb32960-ingest-app: image: crpi-85r4m0ackrm3qpje.cn-shanghai.personal.cr.aliyuncs.com/oneos/gb32960-ingest-app:${LINGNIU_IMAGE_VERSION:?set LINGNIU_IMAGE_VERSION} @@ -77,11 +83,8 @@ services: networks: - vehicle-ingest healthcheck: + <<: *readiness-healthcheck test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:20100/actuator/health/readiness >/dev/null"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 60s jt808-ingest-app: image: crpi-85r4m0ackrm3qpje.cn-shanghai.personal.cr.aliyuncs.com/oneos/jt808-ingest-app:${LINGNIU_IMAGE_VERSION:?set LINGNIU_IMAGE_VERSION} @@ -106,11 +109,8 @@ services: networks: - vehicle-ingest healthcheck: + <<: *readiness-healthcheck test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:20400/actuator/health/readiness >/dev/null"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 60s yutong-mqtt-app: image: crpi-85r4m0ackrm3qpje.cn-shanghai.personal.cr.aliyuncs.com/oneos/yutong-mqtt-app:${LINGNIU_IMAGE_VERSION:?set LINGNIU_IMAGE_VERSION} @@ -142,11 +142,8 @@ services: networks: - vehicle-ingest healthcheck: + <<: *readiness-healthcheck test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:20500/actuator/health/readiness >/dev/null"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 60s vehicle-history-app: image: crpi-85r4m0ackrm3qpje.cn-shanghai.personal.cr.aliyuncs.com/oneos/vehicle-history-app:${LINGNIU_IMAGE_VERSION:?set LINGNIU_IMAGE_VERSION} @@ -183,11 +180,8 @@ services: networks: - vehicle-ingest healthcheck: + <<: *readiness-healthcheck test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:20200/actuator/health/readiness >/dev/null"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 60s vehicle-analytics-app: image: crpi-85r4m0ackrm3qpje.cn-shanghai.personal.cr.aliyuncs.com/oneos/vehicle-analytics-app:${LINGNIU_IMAGE_VERSION:?set LINGNIU_IMAGE_VERSION} @@ -213,11 +207,8 @@ services: networks: - vehicle-ingest healthcheck: + <<: *readiness-healthcheck test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:20300/actuator/health/readiness >/dev/null"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 60s networks: vehicle-ingest: diff --git a/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/PortainerComposeResourceLimitsTest.java b/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/PortainerComposeResourceLimitsTest.java index caf9b0be..2a84e2df 100644 --- a/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/PortainerComposeResourceLimitsTest.java +++ b/modules/apps/vehicle-history-app/src/test/java/com/lingniu/ingest/historyapp/PortainerComposeResourceLimitsTest.java @@ -45,6 +45,12 @@ class PortainerComposeResourceLimitsTest { String dockerfile = Files.readString(repositoryRoot().resolve("Dockerfile")); assertThat(dockerfile).contains("apt-get install -y --no-install-recommends curl"); + assertThat(compose) + .contains("x-readiness-healthcheck: &readiness-healthcheck\n" + + " interval: 30s\n" + + " timeout: 5s\n" + + " retries: 3\n" + + " start_period: 60s"); assertServiceReadinessHealthcheck(compose, "gb32960-ingest-app", "20100"); assertServiceReadinessHealthcheck(compose, "jt808-ingest-app", "20400"); assertServiceReadinessHealthcheck(compose, "yutong-mqtt-app", "20500"); @@ -398,12 +404,13 @@ class PortainerComposeResourceLimitsTest { private static void assertServiceReadinessHealthcheck(String compose, String serviceName, String httpPort) { assertThat(serviceBlock(compose, serviceName)) .contains(" healthcheck:\n") + .contains(" <<: *readiness-healthcheck\n") .contains(" test: [\"CMD-SHELL\", \"curl -fsS http://127.0.0.1:" + httpPort + "/actuator/health/readiness >/dev/null\"]") - .contains(" interval: 30s\n") - .contains(" timeout: 5s\n") - .contains(" retries: 3\n") - .contains(" start_period: 60s\n"); + .doesNotContain(" interval: 30s\n") + .doesNotContain(" timeout: 5s\n") + .doesNotContain(" retries: 3\n") + .doesNotContain(" start_period: 60s\n"); } private static String serviceBlock(String compose, String serviceName) {