Files
wecom-ai-assistant/docs/private-registry-setup.md
2026-02-05 20:09:07 +08:00

4.1 KiB
Raw Permalink Blame History

私有仓库和 Docker Registry 配置指南

概述

项目已配置为使用私有 Git 仓库和私有 Docker Registry

配置信息

Git 仓库配置

Docker Registry 配置

配置文件:.registry-config(不提交到 Git

REGISTRY_URL=git.quanyu360.cn
REGISTRY_USERNAME=admin
REGISTRY_PASSWORD=ye972030
REGISTRY_NAMESPACE=wecom-ai
BACKEND_IMAGE_NAME=wecom-ai-backend
ADMIN_IMAGE_NAME=wecom-ai-admin

使用方法

1. 推送代码到私有仓库

默认推送到私有仓库

# 使用脚本(推荐)
.\scripts\push-to-private-repo.ps1

# 或手动推送
git push private main

推送到 GitHub

# 使用脚本
.\scripts\push-to-private-repo.ps1 -PushToGitHub

# 或手动推送
git push origin main

推送到两个仓库

# 使用脚本
.\scripts\push-to-private-repo.ps1 -PushToBoth

# 或手动推送
git push private main
git push origin main

2. 构建并推送 Docker 镜像

测试 Registry 连接

.\scripts\test-registry-connection.ps1

推送所有镜像

# 推送所有镜像backend + admin
.\scripts\push-images-to-private-registry.ps1 -BuildAll

# 或指定标签
.\scripts\push-images-to-private-registry.ps1 -BuildAll -Tag v1.0.0

只推送 Backend 镜像

.\scripts\push-images-to-private-registry.ps1 -BuildBackend

只推送 Admin 镜像

.\scripts\push-images-to-private-registry.ps1 -BuildAdmin

3. 在生产环境使用私有镜像

更新 docker-compose.prod.yml 中的环境变量:

# 在 .env.prod 中设置
REGISTRY_URL=git.quanyu360.cn
REGISTRY_NAMESPACE=wecom-ai
IMAGE_TAG=latest

或在服务器上登录 Registry

docker login git.quanyu360.cn -u admin -p ye972030

然后使用 docker-compose 部署:

docker-compose -f docker-compose.prod.yml --env-file .env.prod up -d

镜像命名规则

推送后的镜像地址:

  • Backend: git.quanyu360.cn/wecom-ai/wecom-ai-backend:latest
  • Admin: git.quanyu360.cn/wecom-ai/wecom-ai-admin:latest

验证配置

检查 Git 远程仓库

git remote -v

应该看到:

  • origin → GitHub 仓库
  • private → 私有仓库

检查 Docker Registry 登录

docker login git.quanyu360.cn -u admin -p ye972030

测试 Registry 连接

.\scripts\test-registry-connection.ps1

更新配置

修改 Registry 配置

编辑 .registry-config 文件:

REGISTRY_URL=新的registry地址
REGISTRY_USERNAME=新的用户名
REGISTRY_PASSWORD=新的密码

修改 Git 远程仓库

# 更新私有仓库地址
git remote set-url private https://admin:password@git.quanyu360.cn/admin/wecom-ai-assistant.git

# 验证
git remote -v

安全建议

  1. 配置文件安全

    • .registry-config 已添加到 .gitignore
    • 不要将密码提交到 Git
    • 定期更新密码
  2. Docker 凭据

    • 使用 Docker Credential Helper 存储凭据
    • 或在 CI/CD 中使用 Secrets
  3. 访问控制

    • 限制 Registry 访问权限
    • 使用只读用户进行拉取操作

故障排查

问题Docker 登录失败

检查项

  1. Registry URL 是否正确
  2. 用户名和密码是否正确
  3. Registry 服务是否正常运行
  4. 网络连接是否正常

问题:推送镜像失败

解决方案

  1. 确认已登录 Registry
  2. 检查镜像名称格式是否正确
  3. 确认有推送权限

问题Git 推送失败

解决方案

  1. 检查远程仓库地址是否正确
  2. 确认用户名和密码正确
  3. 检查网络连接

相关文档