更新指南
更新到最新版本
Section titled “更新到最新版本”标准更新流程
Section titled “标准更新流程”# 拉取最新镜像docker compose pull
# 重启服务(数据库迁移自动执行)docker compose up -d
# 验证服务状态docker compose ps查看更新日志
Section titled “查看更新日志”# 查看后端日志docker compose logs backend
# 确认迁移成功docker compose logs backend | grep "migration"更新到特定版本
Section titled “更新到特定版本”使用环境变量
Section titled “使用环境变量”# 设置版本号export IMAGE_TAG=v1.2.0
# 或在 .env 文件中设置echo "IMAGE_TAG=v1.2.0" >> .env
# 拉取并重启docker compose pulldocker compose up -d修改 docker-compose.yml
Section titled “修改 docker-compose.yml”直接修改镜像标签:
services: backend: image: ghcr.io/leslieleung/glean-backend:v1.2.0 web: image: ghcr.io/leslieleung/glean-web:v1.2.0 admin: image: ghcr.io/leslieleung/glean-admin:v1.2.0测试预发布版本
Section titled “测试预发布版本”预发布版本(alpha/beta/rc)用于测试新功能:
# 使用预发布版本IMAGE_TAG=v1.3.0-alpha.1 docker compose up -d如果更新后出现问题,可以回滚到之前的版本:
# 停止服务docker compose down
# 设置旧版本export IMAGE_TAG=v1.1.0
# 启动旧版本docker compose up -d数据库迁移
如果新版本执行了数据库迁移,回滚可能需要手动处理数据库。建议在更新前备份数据库。
更新前检查清单
Section titled “更新前检查清单”-
备份数据
Terminal window docker exec glean-postgres pg_dump -U glean glean | gzip > backup_before_update.sql.gz -
查看变更日志
- 访问 GitHub Releases
- 阅读版本更新说明
-
检查破坏性变更
- 注意 Breaking Changes 标记
- 检查配置变量变更
-
准备回滚方案
- 记录当前版本
- 确保有有效备份
检查服务状态
Section titled “检查服务状态”# 所有服务应该是 healthy 状态docker compose ps
# 预期输出示例# NAME STATUS# glean-backend Up (healthy)# glean-worker Up# glean-web Up# glean-admin Up# glean-postgres Up (healthy)# glean-redis Up (healthy)检查 API 健康
Section titled “检查 API 健康”curl http://localhost/api/health# 检查是否有错误docker compose logs --tail=100 backend | grep -i error
# 检查 workerdocker compose logs --tail=100 worker | grep -i error使用 Watchtower(可选)
Section titled “使用 Watchtower(可选)”Watchtower 可以自动更新 Docker 容器:
docker run -d \ --name watchtower \ -v /var/run/docker.sock:/var/run/docker.sock \ containrrr/watchtower \ --cleanup \ --interval 86400 \ glean-backend glean-web glean-admin glean-worker更新时间窗口
Section titled “更新时间窗口”建议在以下时间更新:
- 用户活跃度低的时段
- 有充足时间处理潜在问题
- 确保有人员可响应异常