Просмотр исходного кода

feat(docker): add healthcheck to service and update Dockerfile to include curl

- Introduced a healthcheck for the service in docker-compose.yaml to ensure it is running correctly.
- Updated Dockerfile to install curl, which is required for the healthcheck functionality.
- Added 'endpoint' field to various language JSON files for improved localization support in the dashboard.
- Updated error details dialog to display endpoint information and adjusted usage logs table to pass endpoint data.
ding113 5 месяцев назад
Родитель
Сommit
f3ee76f39e

+ 1 - 1
deploy/Dockerfile

@@ -28,7 +28,7 @@ ENV PORT=3000
 ENV HOST=0.0.0.0
 WORKDIR /app
 
-# 安装 PostgreSQL 18 客户端工具(用于数据库备份/恢复功能)
+# 安装 PostgreSQL 18 客户端工具(用于数据库备份/恢复功能)和 curl(用于健康检查)
 # 需要使用官方 PostgreSQL APT 仓库以获取最新版本
 RUN apt-get update && \
     apt-get install -y gnupg curl ca-certificates && \

+ 6 - 0
docker-compose.yaml

@@ -66,3 +66,9 @@ services:
     ports:
       - "${APP_PORT:-23000}:${APP_PORT:-23000}"
     restart: unless-stopped
+    healthcheck:
+      test: ["CMD-SHELL", "curl -f http://localhost:${APP_PORT:-23000}/api/actions/health || exit 1"]
+      interval: 30s
+      timeout: 5s
+      retries: 3
+      start_period: 30s

+ 1 - 0
messages/ja/dashboard.json

@@ -80,6 +80,7 @@
       "key": "キー",
       "provider": "プロバイダー",
       "model": "モデル",
+      "endpoint": "エンドポイント",
       "inputTokens": "入力",
       "outputTokens": "出力",
       "cacheWrite": "キャッシュ書き込み",

+ 1 - 0
messages/ru/dashboard.json

@@ -80,6 +80,7 @@
       "key": "Ключ",
       "provider": "Поставщик",
       "model": "Модель",
+      "endpoint": "Эндпоинт",
       "inputTokens": "Вход",
       "outputTokens": "Выход",
       "cacheWrite": "Запись в кэш",

+ 1 - 0
messages/zh-CN/dashboard.json

@@ -80,6 +80,7 @@
       "key": "密钥",
       "provider": "供应商",
       "model": "模型",
+      "endpoint": "端点",
       "inputTokens": "输入",
       "outputTokens": "输出",
       "cacheWrite": "缓存写入",

+ 1 - 0
messages/zh-TW/dashboard.json

@@ -80,6 +80,7 @@
       "key": "金鑰",
       "provider": "供應商",
       "model": "模型",
+      "endpoint": "端點",
       "inputTokens": "輸入",
       "outputTokens": "輸出",
       "cacheWrite": "快取寫入",

+ 14 - 0
src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx

@@ -29,6 +29,7 @@ interface ErrorDetailsDialogProps {
   currentModel?: string | null; // 当前模型(重定向后)
   userAgent?: string | null; // User-Agent
   messagesCount?: number | null; // Messages 数量
+  endpoint?: string | null; // API 端点
 }
 
 export function ErrorDetailsDialog({
@@ -42,6 +43,7 @@ export function ErrorDetailsDialog({
   currentModel,
   userAgent,
   messagesCount,
+  endpoint,
 }: ErrorDetailsDialogProps) {
   const t = useTranslations("dashboard");
   const tChain = useTranslations("provider-chain");
@@ -236,6 +238,18 @@ export function ErrorDetailsDialog({
             </div>
           )}
 
+          {/* Endpoint 信息 */}
+          {endpoint && (
+            <div className="space-y-2">
+              <h4 className="font-semibold text-sm">{t("logs.columns.endpoint")}</h4>
+              <div className="rounded-md border bg-muted/50 p-3">
+                <code className="text-xs font-mono break-all">
+                  {endpoint}
+                </code>
+              </div>
+            </div>
+          )}
+
           {/* 模型重定向信息 */}
           {originalModel && currentModel && originalModel !== currentModel && (
             <div className="space-y-2">

+ 2 - 15
src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx

@@ -78,7 +78,6 @@ export function UsageLogsTable({
           <TableHeader>
             <TableRow>
               <TableHead>{t("logs.columns.time")}</TableHead>
-              <TableHead>{t("logs.columns.endpoint")}</TableHead>
               <TableHead>{t("logs.columns.user")}</TableHead>
               <TableHead>{t("logs.columns.key")}</TableHead>
               <TableHead>{t("logs.columns.provider")}</TableHead>
@@ -95,7 +94,7 @@ export function UsageLogsTable({
           <TableBody>
             {logs.length === 0 ? (
               <TableRow>
-                <TableCell colSpan={13} className="text-center text-muted-foreground">
+                <TableCell colSpan={12} className="text-center text-muted-foreground">
                   {t("logs.table.noData")}
                 </TableCell>
               </TableRow>
@@ -115,19 +114,6 @@ export function UsageLogsTable({
                     <TableCell className="font-mono text-xs">
                       <RelativeTime date={log.createdAt} fallback="-" />
                     </TableCell>
-                    <TableCell className="min-w-[200px] align-top">
-                      <div className="flex flex-col gap-1">
-                        <span className="font-mono text-xs break-words">{log.endpoint ?? "-"}</span>
-                        {isNonBilling && (
-                          <Badge
-                            variant="outline"
-                            className="w-fit border-orange-200 bg-orange-50 text-orange-700 dark:border-orange-900/60 dark:bg-orange-950/30 dark:text-orange-200"
-                          >
-                            {t("logs.table.nonBilling")}
-                          </Badge>
-                        )}
-                      </div>
-                    </TableCell>
                     <TableCell>{log.userName}</TableCell>
                     <TableCell className="font-mono text-xs">{log.keyName}</TableCell>
                     <TableCell className="text-left">
@@ -240,6 +226,7 @@ export function UsageLogsTable({
                         currentModel={log.model}
                         userAgent={log.userAgent}
                         messagesCount={log.messagesCount}
+                        endpoint={log.endpoint}
                       />
                     </TableCell>
                   </TableRow>