[GH-ISSUE #178] [Bug] Docker Compose 部署方式无法在后台面板检查更新 #136

Closed
opened 2026-02-27 07:18:10 +03:00 by kerem · 2 comments
Owner

Originally created by @moonjoke001 on GitHub (Jan 8, 2026).
Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/178

问题描述

使用 Docker Compose 方式部署时,后台面板的"检查更新"功能无法检测到最新版本,始终显示"已是最新版本"。

环境信息

  • 部署方式: Docker Compose
  • 当前版本: v2.3.8
  • 最新版本: v2.4.6
  • 镜像: justlikemaki/aiclient-2-api:latest

复现步骤

  1. 使用 docker compose up -d 启动服务
  2. 登录后台面板
  3. 点击"检查更新"按钮
  4. 显示"已是最新版本 v2.3.8",但实际最新版本是 v2.4.6

原因分析

检查更新功能 (checkForUpdates) 的逻辑:

  1. 先通过 git rev-parse --git-dir 检测是否在 Git 仓库中
  2. 如果是 Git 仓库,使用 git fetch --tags 获取最新 tags
  3. 如果不是 Git 仓库,使用 GitHub API 获取最新版本

问题在于:Docker 容器内没有安装 git 命令,但代码只检测了 .git 目录是否存在,没有检测 git 命令是否可用。导致:

  • git rev-parse --git-dir 失败(因为没有 git 命令)
  • 代码判断为"非 Git 仓库",理论上应该走 GitHub API
  • 但实际执行时可能因为其他原因导致检测失败

建议修复方案

修改 src/ui-manager.js 中的 checkForUpdates 函数,先检测 git 命令是否可用:

// 检查 git 命令是否可用且在 git 仓库中
let isGitRepo = false;
try {
    // 先检查 git 命令是否存在
    await execAsync('git --version');
    // 再检查是否在 git 仓库中
    await execAsync('git rev-parse --git-dir');
    isGitRepo = true;
} catch (error) {
    isGitRepo = false;
    console.log('[Update] Git not available or not in a Git repository, will use GitHub API to check for updates');
}

临时解决方案

Docker 用户升级需要手动拉取新镜像:

docker compose down
docker compose pull
docker compose up -d
Originally created by @moonjoke001 on GitHub (Jan 8, 2026). Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/178 ## 问题描述 使用 Docker Compose 方式部署时,后台面板的"检查更新"功能无法检测到最新版本,始终显示"已是最新版本"。 ## 环境信息 - **部署方式**: Docker Compose - **当前版本**: v2.3.8 - **最新版本**: v2.4.6 - **镜像**: justlikemaki/aiclient-2-api:latest ## 复现步骤 1. 使用 `docker compose up -d` 启动服务 2. 登录后台面板 3. 点击"检查更新"按钮 4. 显示"已是最新版本 v2.3.8",但实际最新版本是 v2.4.6 ## 原因分析 检查更新功能 (`checkForUpdates`) 的逻辑: 1. 先通过 `git rev-parse --git-dir` 检测是否在 Git 仓库中 2. 如果是 Git 仓库,使用 `git fetch --tags` 获取最新 tags 3. 如果不是 Git 仓库,使用 GitHub API 获取最新版本 **问题在于**:Docker 容器内没有安装 `git` 命令,但代码只检测了 `.git` 目录是否存在,没有检测 `git` 命令是否可用。导致: - `git rev-parse --git-dir` 失败(因为没有 git 命令) - 代码判断为"非 Git 仓库",理论上应该走 GitHub API - 但实际执行时可能因为其他原因导致检测失败 ## 建议修复方案 修改 `src/ui-manager.js` 中的 `checkForUpdates` 函数,先检测 `git` 命令是否可用: ```javascript // 检查 git 命令是否可用且在 git 仓库中 let isGitRepo = false; try { // 先检查 git 命令是否存在 await execAsync('git --version'); // 再检查是否在 git 仓库中 await execAsync('git rev-parse --git-dir'); isGitRepo = true; } catch (error) { isGitRepo = false; console.log('[Update] Git not available or not in a Git repository, will use GitHub API to check for updates'); } ``` ## 临时解决方案 Docker 用户升级需要手动拉取新镜像: ```bash docker compose down docker compose pull docker compose up -d ```
kerem closed this issue 2026-02-27 07:18:10 +03:00
Author
Owner

@justlovemaki commented on GitHub (Jan 8, 2026):

v2.4.6 版本之后可以

<!-- gh-comment-id:3721810909 --> @justlovemaki commented on GitHub (Jan 8, 2026): v2.4.6 版本之后可以
Author
Owner

@moonjoke001 commented on GitHub (Jan 8, 2026):

谢谢

<!-- gh-comment-id:3722064945 --> @moonjoke001 commented on GitHub (Jan 8, 2026): 谢谢
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#136
No description provided.