Files
42_124/CT124_Gitea操作手冊_20260622.md
Timmy 441c2d5a24 新增 CT124 Gitea 操作手冊
操作/clone/資料位置;備份改用 gitea dump(含 DB),並註記開放註冊。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 21:47:39 +08:00

66 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.
# CT124 Gitea(自架 Git 服務)— 操作手冊
> 主機:CT124192.168.42.124Ubuntu 24.04 LXC | 位置:`/opt/gitea`
> 用途:自架 Git 託管(本 `42_124` repo 即放在此:`http://192.168.42.124:31337/timmy/42_124`)
---
## 一、基本資訊
- 版本:**Gitea 1.25.4** + **PostgreSQL 14**`gitea/gitea:latest``postgres:14`
- 容器:`gitea``gitea-db-1`(皆 `restart: always`,共用內網 `gitea`
- 埠:`31337 → 3000`Web`31338 → 22`Git over SSH
- 對外:**僅 LAN**`git/gitea.lotimmy.com` 皆不解析,`ROOT_URL=http://192.168.42.124:31337/`
- 註冊:`DISABLE_REGISTRATION = false`**開放註冊**(見注意事項)
## 二、操作
```bash
cd /opt/gitea
./start.sh # = docker-compose up -d
./stop.sh # = docker-compose down
docker compose logs -f
docker compose restart
```
## 三、存取與 clone
```bash
# Web
http://192.168.42.124:31337
# HTTP clone
git clone http://192.168.42.124:31337/<user>/<repo>.git
# SSH clone(注意走 31338,非 22)
git clone ssh://git@192.168.42.124:31338/<user>/<repo>.git
```
## 四、資料與設定
| 項目 | 位置 / 值 |
|---|---|
| Gitea 應用資料(repos/config/上傳) | `./data`(→ 容器 `/data`) |
| 設定檔 | `./data/gitea/conf/app.ini` |
| PostgreSQL 資料 | `./postgres` |
| DB 連線 | `db:5432`,gitea/gitea(內網,環境變數帶入) |
## 五、備份
> ⚠️ **舊 README 只 `tar data/` 不夠** —— 現在中繼資料在 PostgreSQL,光打包 `data/` 會缺 DB,
> 且對運行中的 `postgres/` 直接 tar 不保證一致。正確做法用 Gitea 內建 dump:
```bash
# 產出含 repos + DB + 設定的單一壓縮檔(寫到容器 /data,即 host ./data)
docker exec -u git gitea gitea dump -c /data/gitea/conf/app.ini
# 取出
mv /opt/gitea/data/gitea-dump-*.zip /opt/gitea/
```
`gitea-backup-20260309.tar.gz` 是早期的 `tar data/` 手動備份,僅供參考。)
## 六、注意事項
- **開放註冊**:`DISABLE_REGISTRATION = false`,任何能連到 `:31337` 的人都能註冊帳號。雖僅 LAN,要鎖就在 `app.ini``DISABLE_REGISTRATION = true``docker compose restart`
- SSH clone 必須用 **31338**;app.ini 的 `SSH_PORT = 22` 是容器內埠,Gitea 介面產生的 clone URL 可能顯示 22,手動改成 31338。
- `/opt/gitea` 自身是個 git repo(有自己的 `push.sh`/`CLAUDE.md`),其 remote 與 post-receive hook 是該部署目錄的設定,與使用者 repo 無關。