ci(deploy): support pulling published docker images

This commit is contained in:
2026-07-07 10:09:02 +08:00
parent d1a93c5fe4
commit 5030780cbe
6 changed files with 196 additions and 15 deletions
+36
View File
@@ -79,3 +79,39 @@ docker image ls | grep cozsweet-web
```
如果使用 Gitea 自带 Container Registry,需要确认 Gitea 服务已开启 packages / container registry,并且 `REGISTRY_HOST` 与 Docker 登录地址一致。
## 部署服务器拉取镜像
部署服务器需要先登录镜像仓库:
```bash
docker login REGISTRY_HOST
```
然后在部署服务器工作树中创建 `.deploy.env`
```bash
cp env-example/.deploy.env.example .deploy.env
```
配置示例:
```env
COZSWEET_DEPLOY_IMAGE_SOURCE=pull
COZSWEET_REGISTRY_IMAGE=registry.example.com/cozsweet/cozsweet-web
```
`post-receive` 会根据当前分支和 commit 自动拉取:
```bash
registry.example.com/cozsweet/cozsweet-web:test-<short_sha>
registry.example.com/cozsweet/cozsweet-web:prod-<short_sha>
```
如果需要改用 latest tag,可以在服务器 `.deploy.env` 中显式设置:
```env
COZSWEET_REMOTE_IMAGE_TAG=prod-latest
```
推荐优先使用默认的 `<env>-<short_sha>` 精确 tag,这样发布和回滚都更可控。