Files
gitea/README.md

95 lines
1.7 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.
# Gitea 局域网部署
使用 Docker Compose 部署的 Gitea Git 服务。
## 快速开始
### 1. 配置环境变量
复制并编辑 `.env` 文件:
```bash
cp .env.example .env
```
修改端口等配置:
```env
HTTP_PORT=3000 # Web 界面端口
SSH_PORT=2222 # SSH 端口(宿主机端口,容器内仍为 22
```
> `GITEA__server__SSH_PORT` 已通过 `.env` 传递给容器,告知 Gitea 对外 SSH 端口为 `2222`
> 使 Web 界面中的 SSH clone 地址正确显示端口号。
### 2. 启动服务
```bash
docker compose up -d
```
### 3. 初始配置
首次访问 `http://<服务器IP>:3000` 会进入安装向导:
1. 设置管理员账户
2. 配置服务器域名(可选)
3. 数据库已默认使用 SQLite
## 访问方式
| 方式 | 地址 |
|-----|------|
| Web 界面 | `http://<IP>:3000` |
| HTTP 克隆 | `git clone http://<IP>:3000/<用户>/<仓库>.git` |
| SSH 克隆 | `git clone ssh://git@<IP>:2222/<用户>/<仓库>.git` |
## Git LFS
已启用 Git LFS 支持,使用方法:
```bash
git lfs install
git lfs track "*.psd"
git add .gitattributes
git commit -m "Track PSD files with LFS"
git push
```
## 数据备份
备份 `data/` 目录:
```bash
# 备份
tar -czvf gitea-backup-$(date +%Y%m%d).tar.gz data/
# 恢复
tar -xzvf gitea-backup-20260320.tar.gz
```
重要文件:
- `data/gitea/gitea.db` - 用户和配置数据
- `data/git/repositories/` - 仓库数据
- `data/git/lfs/` - LFS 文件
## 常用命令
```bash
# 启动
docker compose up -d
# 停止
docker compose down
# 查看日志
docker compose logs -f
# 重启
docker compose restart
# 更新版本
# 修改 .env 中的 GITEA_VERSION 后
docker compose up -d
```