Files
springboot-cici-demo/doc/devops/gitlab/README.md
yangzelin 10fcba4f90
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 15s
refactor: 整理 Docker 资产并补充可复制 CI/CD 部署文档
2026-12-04 14:53:04 +08:00

37 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CI/CD 可复制部署文档(Gitea / GitLab)
> 目录名沿用 `gitlab`,但按需求同时记录 **Gitea Actions** 与 **GitLab CI** 的可复制部署方法。本次实际跑通的是 Gitea 链路,GitLab 文件已同步写好,换环境时按本文 checklist 操作即可复现。
## 交付物与位置
| 内容 | 路径 |
|---|---|
| Gitea Actions 工作流 | `.gitea/workflows/cicd.yaml` |
| GitLab CI 工作流 | `.gitlab-ci.yml` |
| 镜像构建文件 | `doc/devops/docker/Dockerfile` |
| 生产启动脚本 | `doc/devops/docker/java-run.sh` |
| 启动脚本测试 | `doc/devops/docker/test-java-run.sh` |
| Docker 资产说明 | `doc/devops/docker/README.md` |
| Gitea runner 创建 | `doc/devops/gitlab/gitea-act-runner.md` |
| 自定义 runner 镜像 | `doc/devops/gitlab/custom-runner-image.md` |
| Workflow 编写指南 | `doc/devops/gitlab/workflow-guide.md` |
| 问题与修复记录 | `doc/devops/gitlab/issues-and-fixes.md` |
## 新环境复制 Checklist
1. **代码仓库**:在 Gitea 创建空仓库(如 `poc/springboot-cici-demo`),把代码 push 到 `master`/`main`。
2. **仓库 Secrets**:Settings → Secrets → Actions 添加 `REGISTRY_USERNAME`、`REGISTRY_PASSWORD`;或用 API(见 `workflow-guide.md`),字段必须是 `data`。
3. **Docker 网络**:确认 Gitea 容器与 runner 容器在同一 Docker network,runner 内可用 `wget http://gitea:3000/api/healthz` 访问 Gitea。
4. **Runner**:按 `gitea-act-runner.md` 注册,标签必须包含 `ubuntu-latest`(与 workflow 的 `runs-on` 一致),并挂载 `/var/run/docker.sock`。
5. **Runner 镜像**:按 `custom-runner-image.md` 构建 `gitea/act_runner:0.6.1-ci`,否则 `actions/checkout@v4` 会因缺 node 失败,docker 步骤会因缺 docker CLI 失败。
6. **Workflow**:按 `workflow-guide.md` 核对 `.gitea/workflows/cicd.yaml` 中的分支、镜像名、`-f doc/devops/docker/Dockerfile` 路径。
7. **触发验证**:push 任意提交,确认 Actions run 为 success;检查镜像短 SHA 与 `latest` tag;用 `docker run` 冒烟 `/api/hello`。
8. **GitLab(可选)**:在 GitLab 项目 Variables 配置同名的两个掩码变量,`.gitlab-ci.yml` 使用同一 Dockerfile,runner 需支持 Docker-in-Docker。
## 网络与账号前提
- Maven Central、Docker Hub 可达(builder 镜像拉依赖、runner 拉 checkout action)。
- 阿里云镜像仓库 `registry.cn-hangzhou.aliyuncs.com/lightjob` 账号具备推送权限。
- Gitea 管理员权限(用于生成 runner token)。
- 容器内访问 Gitea 使用 **Docker 网络别名** `http://gitea:3000`,不要用宿主机内网 IP。