修复容器健康检查失败的核心问题:IPv6 vs IPv4 和权限
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Failing after 3m47s
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Failing after 3m47s
问题诊断(本地运行镜像验证): 1. 服务实际已启动在 3000 端口 2. 从宿主机访问健康检查 ✅ 成功 3. 容器内部 wget localhost:3000 ❌ 失败 (Connection refused) 4. 健康检查尝试连接 [::1]:3000 (IPv6),但 Fiber 只监听 IPv4 根本原因: - wget localhost 优先解析为 IPv6 地址 [::1] - Fiber 默认监听 0.0.0.0:3000 (仅 IPv4) - Docker 健康检查失败 → 容器标记 unhealthy → Worker 无法启动 修复内容: 1. Dockerfile.api 健康检查: localhost → 127.0.0.1 (强制 IPv4) 2. docker-compose.prod.yml 健康检查: 同步修改 3. Dockerfile.api: 创建 logs 目录并设置 appuser 权限 4. cmd/api/main.go: OpenAPI 文档路径改为 logs/openapi.yaml
This commit is contained in:
@@ -20,7 +20,7 @@ services:
|
||||
networks:
|
||||
- junhong-network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/health"]
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3000/health"]
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
||||
Reference in New Issue
Block a user