forked from DevOps/deploy.stack
feat(hindsight): 新增 Hindsight 方案三部署 stack
采用 DB+Hindsight 分离部署方案: - pgvector/pgvector:pg18 向量数据库 - ghcr.nju.edu.cn/vectorize-io/hindsight:latest 应用 - 0.0.0.0:8888/9999 端口绑定 - ~/hindsight/pgdata bind mount (避免 9P fsync 性能) - HF_CACHE_DIR 参数化,适配非 WSL 环境 - 每日 pg_dump 备份,7 天保留 参考 Obsidian 知识库 DevOps/04-AI工具/Hindsight部署指南.md
This commit is contained in:
71
hindsight/stack.yml
Normal file
71
hindsight/stack.yml
Normal file
@@ -0,0 +1,71 @@
|
||||
# Hindsight 部署栈
|
||||
# ============================================================
|
||||
# 部署前准备(仅首次):
|
||||
# mkdir -pv /home/geng/hindsight/pgdata /home/geng/hindsight/backups
|
||||
# sudo chown -R 999:999 /home/geng/hindsight/pgdata
|
||||
# cp env.cfg.example env.cfg && $EDITOR env.cfg # 填入密码/API Key
|
||||
#
|
||||
# pull:: docker compose --env-file ./hindsight/env.cfg -f ./hindsight/stack.yml pull
|
||||
# RUN:: docker compose -p hindsight --env-file ./hindsight/env.cfg -f ./hindsight/stack.yml up -d
|
||||
# disc::
|
||||
# - DB 数据 bind 挂到 /home/geng/hindsight/pgdata(WSL 原生 fs,避 9P fsync 风险)
|
||||
# - 复用宿主 HF 缓存(bge + ms-marco 不重下)
|
||||
# - 镜像走南京大学 ghcr 镜像,国内拉得快
|
||||
# - 端口 8888=API, 9999=Admin UI,绑定 0.0.0.0 供 LAN VM 访问
|
||||
# ============================================================
|
||||
|
||||
services:
|
||||
db:
|
||||
image: ${HINDSIGHT_DB_IMAGE}:pg${HINDSIGHT_DB_VERSION:-18}
|
||||
container_name: hindsight-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- POSTGRES_USER=${HINDSIGHT_DB_USER:-hindsight_user}
|
||||
- POSTGRES_PASSWORD=${HINDSIGHT_DB_PASSWORD:?set HINDSIGHT_DB_PASSWORD}
|
||||
- POSTGRES_DB=${HINDSIGHT_DB_NAME:-hindsight_db}
|
||||
- POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ${Volumes_Path}/pgdata:/var/lib/postgresql/${HINDSIGHT_DB_VERSION:-18}/docker
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${HINDSIGHT_DB_USER:-hindsight_user} -d ${HINDSIGHT_DB_NAME:-hindsight_db}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
networks:
|
||||
- hindsight-net
|
||||
|
||||
hindsight:
|
||||
image: ${HINDSIGHT_APP_IMAGE}:${HINDSIGHT_VERSION:-latest}
|
||||
container_name: hindsight-app
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "${HINDSIGHT_API_PORT:-8888}:8888"
|
||||
- "${HINDSIGHT_ADMIN_PORT:-9999}:9999"
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- HINDSIGHT_API_LLM_PROVIDER=${HINDSIGHT_API_LLM_PROVIDER}
|
||||
- HINDSIGHT_API_LLM_API_KEY=${HINDSIGHT_API_LLM_API_KEY:?set HINDSIGHT_API_LLM_API_KEY}
|
||||
- HINDSIGHT_API_LLM_MODEL=${HINDSIGHT_API_LLM_MODEL}
|
||||
- HINDSIGHT_API_LLM_BASE_URL=${HINDSIGHT_API_LLM_BASE_URL}
|
||||
- HINDSIGHT_API_DATABASE_URL=postgresql://${HINDSIGHT_DB_USER}:${HINDSIGHT_DB_PASSWORD}@db:5432/${HINDSIGHT_DB_NAME}
|
||||
- HINDSIGHT_API_LOG_LEVEL=${HINDSIGHT_API_LOG_LEVEL:-info}
|
||||
- HF_HUB_OFFLINE=1
|
||||
- TRANSFORMERS_OFFLINE=1
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
# 复用宿主 HF 缓存,bge + ms-marco 不重下
|
||||
- /home/geng/.cache/huggingface:/home/hindsight/.cache/huggingface
|
||||
- ${Volumes_Path}/backups:/home/hindsight/backups
|
||||
networks:
|
||||
- hindsight-net
|
||||
|
||||
networks:
|
||||
hindsight-net:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user