Переглянути джерело

【新增,部署】容器增加健康检查

compose 增加 healthcheck:带凭据穿透 basic auth 请求 Caddy 反代,仅 200(dsh 真实响应)算健康,401/502 均不算;start_period 120s 覆盖 dsh 首启 bundles 安装。docker compose ps 可直接观察 starting/healthy/unhealthy。README 特性列表同步说明。
PJ568 3 місяців тому
батько
коміт
ae8b2f9d5e
3 змінених файлів з 17 додано та 0 видалено
  1. 1 0
      README.md
  2. 1 0
      README.zh.md
  3. 15 0
      docker-compose.yml

+ 1 - 0
README.md

@@ -9,6 +9,7 @@ Containerized deployment of the [DeepSeek Harness](https://github.com/deepseek-a
 - Self-contained single container: dsh (loopback only, inside the container) + Caddy username/password Basic Auth
 - Configuration and project/session data persisted: bind mount `./data` → `/home/node` (the whole HOME: settings.yaml, API Key, profiles, sessions, storages, plus agent-installed tools under `~/.x-cmd.root`)
 - Runs as non-root (uid 1000); dsh is not exposed directly
+- Built-in health check: `docker compose ps` shows the real service health (`starting`/`healthy`/`unhealthy`), probing dsh through basic auth with credentials
 - Pinnable image version: build argument `DSH_VERSION`
 - CI automatically builds and pushes `ghcr.io/xidong-ai/deepseek-harness-web-docker` (latest + date-time-hash tags)
 - A scheduled CI job checks the dsh upstream daily: on a new version it bumps `DSH_VERSION`, builds and smoke-tests the image, pushes to master on success, or opens an Issue on failure (a failed version is not retried automatically while its Issue is open; manual dispatch bypasses the gate)

+ 1 - 0
README.zh.md

@@ -9,6 +9,7 @@
 - 单容器自包含:dsh(仅容器内 loopback)+ Caddy 基础用户名密码认证(basic auth)
 - 配置与项目/会话数据持久化:bind mount `./data` → `/home/node`(整个 HOME:settings.yaml、API Key、profiles、sessions、storages,及 agent 自装工具 `~/.x-cmd.root`)
 - 非 root 运行(uid 1000),dsh 不直接对外暴露
+- 内置健康检查:`docker compose ps` 直接可见服务真实健康状态(带凭据穿透 basic auth 探测 dsh 响应,`starting`/`healthy`/`unhealthy`)
 - 镜像版本可 pin:构建参数 `DSH_VERSION`
 - CI 自动构建并推送 `ghcr.io/xidong-ai/deepseek-harness-web-docker`(latest + 日期时间 - 哈希 tag)
 - 定时任务每日检查 dsh 上游:有新版本自动提升 `DSH_VERSION`、构建并冒烟测试,通过则推送 master,失败则创建 Issue(存在同版本未关闭 Issue 时不再自动重试,可手动触发强制重试)

+ 15 - 0
docker-compose.yml

@@ -23,3 +23,18 @@ services:
     env_file: .env
     environment:
       - HOME=/home/node
+    # 健康检查:带凭据穿透 basic auth 请求 Caddy 反代,仅 200(dsh 真实响应)算健康;
+    # 401 是 Caddy 层拒绝、502 是 dsh 未就绪,均不算健康。
+    # $$ 转义为字面 $,运行时在容器内展开为 env_file 注入的凭据。
+    # start_period 覆盖 dsh 首启初始化(bundles 安装可能 1-2 分钟)。
+    #
+    # Health check: request through Caddy with credentials; only 200 (dsh actually responding)
+    # counts as healthy — 401 is rejected at the Caddy layer and 502 means dsh is not up yet.
+    # $$ escapes to a literal $, expanded at runtime to the credentials injected via env_file.
+    # start_period covers dsh's first-run init (bundle installation may take 1-2 minutes).
+    healthcheck:
+      test: ["CMD-SHELL", "curl -fsS -u \"$${DSH_AUTH_USER}:$${DSH_AUTH_PASSWORD}\" http://127.0.0.1:3081/ >/dev/null 2>&1 || exit 1"]
+      interval: 30s
+      timeout: 5s
+      retries: 3
+      start_period: 120s