From 17ff0d951e7f7b2d71acadd24b40f4cdf278d9f4 Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 2 Dec 2025 09:36:38 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20docker-compose.yml?= =?UTF-8?q?=20=E4=B8=AD=E6=89=80=E6=9C=89=E6=9C=8D=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E5=81=A5=E5=BA=B7=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - docker-compose.yml 的 healthcheck 覆盖了 Dockerfile 的 HEALTHCHECK - 使用 wget 而不是 curl - 健康检查 URL 不正确,导致所有服务显示 unhealthy 修复: 1. 统一使用 curl -f 代替 wget 2. 修正所有服务的健康检查 URL: - identity-service: /health → /api/v1/health - wallet-service: /health → /api/v1/health - backup-service: /health ✓ (保持不变) - planting-service: /health → /api/v1/health - referral-service: /health ✓ (保持不变) - reward-service: /health ✓ (保持不变) - mpc-service: /api/v1/health ✓ (已正确,改用 curl) - leaderboard-service: /health → /api/health - reporting-service: /health → /api/v1/health - authorization-service: /health ✓ (保持不变,改用 curl) 3. 统一 timeout 为 3s (原来是 10s) 4. admin-web: 优化 timeout 为 3s Docker HEALTHCHECK 机制: - 在容器内部执行 curl localhost:PORT/path - 不经过 Nginx 或外部网络 - 需要与服务实际端点匹配 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- backend/services/docker-compose.yml | 40 +++++++++++++-------------- frontend/admin-web/docker-compose.yml | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/backend/services/docker-compose.yml b/backend/services/docker-compose.yml index b39021fb..cd170e6c 100644 --- a/backend/services/docker-compose.yml +++ b/backend/services/docker-compose.yml @@ -132,9 +132,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/health"] + test: ["CMD", "curl", "-f", "http://localhost:3000/api/v1/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -168,9 +168,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3001/health"] + test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -198,9 +198,9 @@ services: postgres: condition: service_healthy healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3002/health"] + test: ["CMD", "curl", "-f", "http://localhost:3002/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -234,9 +234,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3003/health"] + test: ["CMD", "curl", "-f", "http://localhost:3003/api/v1/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -270,9 +270,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3004/health"] + test: ["CMD", "curl", "-f", "http://localhost:3004/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -306,9 +306,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3005/health"] + test: ["CMD", "curl", "-f", "http://localhost:3005/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -345,9 +345,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3006/api/v1/health"] + test: ["CMD", "curl", "-f", "http://localhost:3006/api/v1/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -381,9 +381,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3007/health"] + test: ["CMD", "curl", "-f", "http://localhost:3007/api/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -417,9 +417,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3008/health"] + test: ["CMD", "curl", "-f", "http://localhost:3008/api/v1/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped @@ -453,9 +453,9 @@ services: kafka: condition: service_started healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3009/health"] + test: ["CMD", "curl", "-f", "http://localhost:3009/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s restart: unless-stopped diff --git a/frontend/admin-web/docker-compose.yml b/frontend/admin-web/docker-compose.yml index f5f343de..4155697b 100644 --- a/frontend/admin-web/docker-compose.yml +++ b/frontend/admin-web/docker-compose.yml @@ -14,7 +14,7 @@ services: healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"] interval: 30s - timeout: 10s + timeout: 3s retries: 3 start_period: 40s networks: