godcall/deploy/global-images/start-memory-hub.sh
type-two 260f02915f GODCALL fork: English UI+prompts, http Gitea fetcher, self-buildable images
- Translate panel UI (~500 strings) and all extraction/wiki prompts to English;
  rebrand to GODCALL (title, logo, login, header)
- git-fetcher: allow http:// clone URLs behind KNOWLEDGE_ALLOW_HTTP=1 (tailnet Gitea)
- MemoryCore/Dockerfile: drop-in image (upstream ships none) with
  TDAI_GATEWAY_CONFIG env + healthcheck; combined-hub Dockerfile: stock Debian
  mirrors; stub MemoryKnowledge openapi.yaml (absent upstream but COPYed)
- start-memory-hub.sh: optional GIT_CREDENTIALS_FILE mount (keeps tokens out of
  repo URLs); tools/import-gitea.mjs: bulk CodeGraph import of all Gitea repos

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-03 21:13:08 +10:00

89 lines
3.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 单独拉起 memory-hubpanel + knowledge 合并镜像,端口 8125 + 8424
#
# 依赖memory 需要先起来memory-hub 里 knowledge 调 memory 做 embed/RAG
# 如果 memory 容器不存在,此脚本会打 warn 但仍继续LLM_MODE=proxy 时 memory-hub
# 自身可以启动,只是 knowledge 首次调 memory 时会失败)。
#
# 用法:
# ./start-memory-hub.sh
#
# 需要以下 LLM 参数(写在 .env
# MEMORY_LLM_BASE_URL / MEMORY_LLM_API_KEY / MEMORY_LLM_MODEL
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=./_lib.sh
source "$SCRIPT_DIR/_lib.sh"
load_env
require_vars \
MEMORY_HUB_IMAGE PANEL_PORT KNOWLEDGE_PORT PANEL_VOLUME \
MEMORY_LLM_BASE_URL MEMORY_LLM_API_KEY MEMORY_LLM_MODEL \
KNOWLEDGE_PUBLIC_BASE_URL
# 与 memory-core 保持一致的 gateway 内部凭据(默认 local仅本地体验
MEMORY_CORE_GATEWAY_API_KEY="${MEMORY_CORE_GATEWAY_API_KEY:-local}"
CONTAINER=tdai-memory-hub
NETWORK=tdai-memory-stack
if ! $DOCKER network inspect "$NETWORK" >/dev/null 2>&1; then
info "创建 docker 网络 $NETWORK"
$DOCKER network create "$NETWORK" >/dev/null
fi
# memory 未起来时给提醒,不阻塞
if ! $DOCKER ps --format '{{.Names}}' 2>/dev/null | grep -qx "tdai-memory-core"; then
warn "memory-core 容器未运行。memory-hub 能启动,但 knowledge 调 memory 时会失败。"
warn "建议先 ./start-memory-core.sh 再来这里,或直接 ./start-all.sh"
fi
rm_container_if_exists "$CONTAINER"
# GODCALL: optional git credentials for private Gitea imports.
# Set GIT_CREDENTIALS_FILE in .env to a git credential-store file
# (one line, e.g. http://user:token@gitea-host:3000). It is mounted read-only
# so tokens never appear in repo URLs, the panel DB, or docker inspect env.
GIT_CRED_ARGS=()
if [[ -n "${GIT_CREDENTIALS_FILE:-}" && -s "$GIT_CREDENTIALS_FILE" ]]; then
GITCONFIG_FILE="$SCRIPT_DIR/.godcall-gitconfig"
printf '[credential]\n\thelper = store --file /root/.git-credentials\n' > "$GITCONFIG_FILE"
GIT_CRED_ARGS+=( -v "$GIT_CREDENTIALS_FILE:/root/.git-credentials:ro" \
-v "$GITCONFIG_FILE:/root/.gitconfig:ro" )
info "git credentials mounted from $GIT_CREDENTIALS_FILE"
fi
# 内部 knowledge 通过 upstream memory 调 LLM 走 custom 模式,直接指向 MEMORY_LLM_*
# LLM_MODE=custom → 不走 memory 的 LLM proxy而是 knowledge 直连用户提供的端点
info "启动 memory-hub (image=$MEMORY_HUB_IMAGE, panel=$PANEL_PORT knowledge=$KNOWLEDGE_PORT)"
$DOCKER run -d --name "$CONTAINER" \
--network "$NETWORK" \
--network-alias memory-hub \
--add-host=host.docker.internal:host-gateway \
-p "${PANEL_PORT}:8125" \
-p "${KNOWLEDGE_PORT}:8424" \
-v "${PANEL_VOLUME}:/data/knowledge" \
${GIT_CRED_ARGS[@]+"${GIT_CRED_ARGS[@]}"} \
-e KNOWLEDGE_ALLOW_HTTP="${KNOWLEDGE_ALLOW_HTTP:-}" \
-e KNOWLEDGE_SSRF_CHECK="${KNOWLEDGE_SSRF_CHECK:-}" \
-e PANEL_PORT=8125 \
-e KNOWLEDGE_PORT=8424 \
-e KNOWLEDGE_PUBLIC_BASE_URL="$KNOWLEDGE_PUBLIC_BASE_URL" \
-e REMOTE_INSTANCE_ID=default \
-e REMOTE_INSTANCE_NAME=default \
-e REMOTE_INSTANCE_URL="http://memory-core:8420" \
-e REMOTE_INSTANCE_KEY="$MEMORY_CORE_GATEWAY_API_KEY" \
-e LLM_MODE=custom \
-e LLM_PROTOCOL="${MEMORY_LLM_PROTOCOL:-openai}" \
-e LLM_API_KEY="$MEMORY_LLM_API_KEY" \
-e LLM_BASE_URL="$MEMORY_LLM_BASE_URL" \
-e LLM_MODEL="$MEMORY_LLM_MODEL" \
-e KNOWLEDGE_LLM_BINDING_SYNC=0 \
"$MEMORY_HUB_IMAGE" >/dev/null
wait_healthy "$CONTAINER" 120
ok "memory-hub 已启动"
ok " Panel UI → http://localhost:${PANEL_PORT}/"
ok " KS Health → http://localhost:${KNOWLEDGE_PORT}/health"