feat(gitea): 部署 gitea 28.2.0 并入库接入草稿

- 容器 gitea/gitea:28.2.0 仅绑 127.0.0.1:13020,管理员 wait4x 经 CLI 创建,
  私有空仓 wait4x/blog 就位(Phase 1 博客源码仓)
- app.ini 种子入库(INSTALL_LOCK 预置,密钥首启生成,快照严禁回覆盖运行时)
- REQUIRE_SIGNIN_VIEW 会 403 匿名 version 端点,与验收冲突已撤,坑记 README
- 凭据不进 git:初始密码并入住主 init-credentials.txt(0600),README 留指引

验证: curl -sf http://127.0.0.1:13020/api/v1/version → {"version":"28.2.0"};
      docker inspect gitea = running;wait4x/blog private+empty 经 API 查证

Co-authored-by: GLM-5.3
This commit is contained in:
wait4xandGLM-5.3 committed 2026-10-24 22:09:06 +08:00
1 parent aea11469e3
commit ddcda54f90
5 files changed
+160 -1

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
# gitea 部署(博客代码托管)
博客重建方案中的自建 git 托管后端:容器只绑 `127.0.0.1:13020`,公网经 nginx 反代为
`https://git.wait4x.online/`。本目录是入库快照,宿主实际运行位置为 `~/docker_apps/gitea/`。
## 文件与同步方向
| 文件 | 作用 |
|------|------|
| `docker-compose.yml` | 容器编排(gitea/gitea:28.2.0,UID/GID 1000,restart unless-stopped) |
| `app.ini` | 首启种子配置;密钥(SECRET_KEY/INTERNAL_TOKEN 等)由首启自动生成 |
| `nginx-git.wait4x.online.conf` | nginx 接入**草稿,未安装**(proxy 头写法对齐主站 halo vhost) |
改动流程:先改本目录 → 拷贝到 `~/docker_apps/gitea/` → `docker compose up -d`。
运行时 app.ini 在宿主 `data/gitea/conf/app.ini`,含首启生成的密钥,
**严禁**用本目录快照回覆盖(密钥丢失 = 加密数据不可解密)。
## 初始化凭据(仅初始化用)
- 管理员:`wait4x`;初始密码与 API token 一并存宿主 `~/docker_apps/gitea/init-credentials.txt`
(0600,不入库——本仓库将公开,凭据不进 git 历史),首登修改后删除该文件敏感行
- API token(scopes=all)存宿主 `~/docker_apps/gitea/init-credentials.txt`(0600,不入库),
供后续 webhook/CI 用,可随时在 gitea UI 撤销重建
## 管理命令速查(均在宿主 `~/docker_apps/gitea/` 下执行)
```bash
# 建用户(关注册实例,账号只能这样建)
docker compose exec -u git gitea gitea admin user create --username <u> --email <e>@wait4x.online --random-password
# 建私有空仓(token 从 init-credentials.txt 取)
curl -X POST http://127.0.0.1:13020/api/v1/user/repos \
-H "Authorization: token <TOKEN>" -H 'Content-Type: application/json' \
-d '{"name":"<repo>","private":true,"auto_init":false}'
# 生成新 token
docker compose exec -u git gitea gitea admin user generate-access-token --username <u> --scopes all --raw
# 改密(含管理员自救)
docker compose exec -u git gitea gitea admin user change-password -u <u> -p <新密码>
```
## 数据备份
全部状态在宿主 `~/docker_apps/gitea/data/`:sqlite(`gitea/gitea.db`)、
裸仓(`git/repositories/`)、LFS 与附件(`gitea/data/`)。
sqlite 直接热拷贝会撕裂,备份前 `docker compose down` 或用 `sqlite3 .backup`;
升级前必须先备份。
## 升级
改 compose 里镜像 tag → `docker compose pull` → `up -d`(首启自动迁移 schema,不可降级)。
## 已知坑
- **不要开 `REQUIRE_SIGNIN_VIEW`**:它会把匿名 `/api/v1/version` 一并 403,
而验收与健康检查都裸 curl 该端点;私有性靠 private 仓 + `DISABLE_REGISTRATION` 保证。
- nginx 的 `client_max_body_size 100M`(git push 大 pack)与 app.ini
`FILE_MAX_SIZE=50`(网页上传单文件)是两条独立限制,别混为一谈。
- vhost 草稿未带 websocket Upgrade 头(与 halo 写法一致);若日后 Actions 实时日志
异常,参照 dpanel vhost 补 Upgrade 头——全局 `map $connection_upgrade` 已在
default 里定义,新 vhost 直接引用即可,勿重复定义。
- SSH 通道整体关闭(不映射 22 + `DISABLE_SSH=true`),克隆统一走 https。
- DNS/ESA 解析 `git.wait4x.online` 尚未配置,nginx 接入由运维会话统一执行,
本目录草稿不自行生效。