Skip to content

feat: 合并 genehub 基因库到主仓库统一维护#250

Open
chenchenchenchencj wants to merge 4 commits into
mainfrom
feat/merge-genehub
Open

feat: 合并 genehub 基因库到主仓库统一维护#250
chenchenchenchencj wants to merge 4 commits into
mainfrom
feat/merge-genehub

Conversation

@chenchenchenchencj
Copy link
Copy Markdown
Collaborator

@chenchenchenchencj chenchenchenchencj commented May 15, 2026

Summary

NoDeskAI/genehub 仓库完整合并到主项目中,统一维护和部署,降低多仓库管理成本。

变更内容

  • genehub/ — 完整的 GeneHub 基因库代码(Registry API + Web 前端 + CLI + SDK + 基因内容)
  • docker-compose.yml — 新增 genehub-registry + genehub-gitea 服务,与主项目共享 Postgres 实例
  • dev.sh — 集成 GeneHub 本地开发:Registry 端口 4520、Web 端口 5173,支持 --skip-genehub 跳过
  • deploy/ — 构建/发布/部署脚本新增 genehub 组件(镜像名 genehub-registry),支持 --skip-genehub
  • deploy/k8s/genehub.yaml — K8s 部署清单(GeneHub Deployment + Service + Gitea)
  • deploy/k8s/ingress.yaml — 新增 GeneHub Ingress 规则
  • Backend 配置GENEHUB_REGISTRY_URL 默认指向内部服务(Docker Compose: http://genehub-registry:3000,本地开发: http://localhost:4520
  • scripts/init-multi-db.sh — Postgres 启动时自动创建 genehub 数据库
  • .env.example — 补充 GeneHub 相关环境变量文档
  • AGENTS.md — 更新开发指南,加入 GeneHub 组件说明

架构决策

  1. 共享 Postgres — genehub 使用独立数据库(默认名 genehub),通过 init-multi-db.sh 自动创建
  2. 独立 Gitea — genehub-gitea 独立容器,用于基因文件版本管理
  3. 内部服务通信 — Backend 通过内网地址 http://genehub-registry:3000 直连 GeneHub API,无需外网
  4. 保留 monorepo 结构 — genehub 内部 pnpm workspace 结构完整保留,独立构建部署

API 兼容性验证

已逐一对照 GeneHubAdapter 调用的 9 条 API 路径与 genehub registry 路由,全部匹配:

  • GET /api/v1/genes (搜索) ✓
  • GET /api/v1/genes/:slug (详情) ✓
  • GET /api/v1/genes/:slug/manifest
  • GET /api/v1/genes/featured
  • GET /api/v1/genes/tags
  • GET /api/v1/genes/:slug/synergies
  • POST /api/v1/genes (发布) ✓
  • POST /api/v1/genes/:slug/installed
  • POST /api/v1/genes/:slug/effectiveness

Test plan

  • docker compose up 验证所有服务正常启动(含 genehub-registry + genehub-gitea)
  • 验证 Backend 通过 GENEHUB_REGISTRY_URL 正常连接 GeneHub Registry API
  • ./dev.sh 验证本地开发所有服务启动正常
  • ./dev.sh --skip-genehub 验证跳过 GeneHub 功能正常
  • 验证 GeneHub Registry 健康检查 GET /api/health 响应正常
  • 验证基因搜索/详情等 API 通过 Backend 正常工作
  • ./deploy/release.sh create <version> 验证 genehub 镜像构建正常

Made with Cursor

- 将 NoDeskAI/genehub 仓库完整复制为 genehub/ 顶层目录
- docker-compose.yml: 新增 genehub-registry + genehub-gitea 服务,共享 Postgres
- dev.sh: 集成 genehub 本地开发(registry 4520 + web 5173),支持 --skip-genehub
- deploy: 构建/发布/部署脚本支持 genehub 组件(镜像 genehub-registry)
- deploy/k8s/genehub.yaml: 统一的 K8s 部署清单(Deployment + Service + Gitea)
- backend config: GENEHUB_REGISTRY_URL 默认指向内部服务
- 新增 scripts/init-multi-db.sh: Postgres 启动时自动创建 genehub 数据库
- .env.example: 补充 GeneHub 相关配置项文档
- AGENTS.md: 更新开发指南反映 GeneHub 组件

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings May 15, 2026 07:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dcf943e53

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread deploy/k8s/genehub.yaml
valueFrom:
secretKeyRef:
name: nodeskclaw-backend-env
key: GENEHUB_DATABASE_URL
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a provisioned DB secret for GeneHub registry

DATABASE_URL is sourced from secret key GENEHUB_DATABASE_URL, but the default init flow builds nodeskclaw-backend-env from nodeskclaw-backend/.env and the provided .env.example does not define this key, so the variable is typically absent. In that case the registry falls back to its localhost default DB URL and cannot connect in K8s, which leaves the new genehub deployment failing out-of-the-box unless operators discover and add an undocumented secret key manually.

Useful? React with 👍 / 👎.

Comment thread deploy/k8s/genehub.yaml Outdated
periodSeconds: 10
volumes:
- name: gitea-data
emptyDir: {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Persist Gitea storage instead of ephemeral emptyDir

The genehub-gitea Deployment mounts its data volume from emptyDir, so all repositories are erased whenever the pod is recreated (restart, reschedule, node drain). Because GeneHub relies on Gitea as the source of truth for gene files, this causes irreversible data loss and breaks registry consistency after routine cluster operations.

Useful? React with 👍 / 👎.

Comment thread dev.sh
wait "$pid" 2>/dev/null || true
done
for port in 4510 4511; do
for port in 4510 4511 4520 5173; do
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid killing unrelated processes on port 5173

Cleanup unconditionally force-kills every PID listening on port 5173, but startup never checks that port is free. If a developer already has another app on 5173, dev.sh will still run (GeneHub web may fail to bind) and Ctrl+C later kills the unrelated process with kill -9, which is an unexpected destructive side effect.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea1db588d3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread deploy/k8s/genehub.yaml
Comment on lines +17 to +19
containers:
- name: genehub
image: <YOUR_REGISTRY>/<YOUR_NAMESPACE>/genehub-registry:latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Run GeneHub schema migrations before serving traffic

This deployment starts genehub-registry directly, but the image command (genehub/Dockerfile runs node dist/index.js) does not apply Drizzle migrations, and the only bootstrap script added here (scripts/init-multi-db.sh) creates databases only, not tables. On a fresh cluster, /api/health will still pass while API routes that query genes/gene_versions fail at runtime because the schema from genehub/packages/registry/drizzle/*.sql was never applied; add an initContainer or startup migration step before the app is marked ready.

Useful? React with 👍 / 👎.

Comment thread docker-compose.yml
image: postgres:16-alpine
volumes:
- pg_data:/var/lib/postgresql/data
- ./scripts/init-multi-db.sh:/docker-entrypoint-initdb.d/init-multi-db.sh:ro
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Ensure GeneHub DB is created for existing Compose volumes

The new DB bootstrap relies on mounting init-multi-db.sh into /docker-entrypoint-initdb.d, but that hook only runs when PostgreSQL initializes an empty data directory; users upgrading with an existing pg_data volume will skip this script, so ${GENEHUB_DB} is never created and genehub-registry cannot connect to postgres:5432/${GENEHUB_DB}. This needs a runtime/upgrade-safe DB creation path instead of an initdb-only hook.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9300fae951

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread deploy/k8s/genehub.yaml
labels:
app: genehub
spec:
initContainers:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add imagePullSecrets to GeneHub pod template

The new genehub Deployment omits imagePullSecrets, while the other workloads in this repo (for example deploy/k8s/backend.yaml and deploy/k8s/portal.yaml) explicitly use cr-pull-secret. In clusters where REGISTRY/PUBLIC_REGISTRY points to a private registry, both the genehub-migrate initContainer and main genehub container will fail with image pull errors (ImagePullBackOff), so GeneHub never becomes available.

Useful? React with 👍 / 👎.

Comment thread deploy/k8s/genehub.yaml
spec:
initContainers:
- name: genehub-migrate
image: <YOUR_REGISTRY>/<YOUR_NAMESPACE>/genehub-registry:latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pin migration initContainer to the same release image

The migration initContainer is hardcoded to genehub-registry:latest, which can diverge from the app version deployed by release tags. During rollouts, this can run migrations from a different build than the main container, causing schema/app mismatches (for example, latest ahead of the tagged app) and startup failures that are hard to reproduce.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants