Files
Deployments/Gitea/README.md

124 lines
4.1 KiB
Markdown
Raw 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.
# Gitea
## 官网
https://gitea.io/en-us/
## 用途
低配置要求的Gitlab替代。
## 文件说明
* `docker-compose.yml`:服务配置;
## 安装说明
1. 解析域名到你的服务器;
2. 安装docker-compose参考 <a href="https://www.4spaces.org/centos-install-docker-compose/" target="_blank">CENTOS安装Docker Compose</a>
3. 完成NginxAndLetsencrypt的部署或acme参看acme项目的实例研究1
参见相关说明。包含把sample.conf改名为gitea.conf或其他名字
4. 在/srv下复制gitea目录。cd进gitea
5. 在/srv/gitea下chmod +x ./grant-permissions.sh
6. 执行该sh脚本。注意可以通过tail -2 /etc/passwd和tail -2 /etc/group 查看新注册用户的uid和gid。如和docker-compose.yml中的不符合则应修改yml文件。
7. 执行docker ps来查看当前的docker实例找到其中的nginx实例
......
84e4e7a719e8 nginx:latest "/bin/sh -c 'while :…" 17 months ago Up 5 weeks 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp **<u>nginx_nginx_1</u>**
8. 执行 docker inspect nginx_nginx_1来确定nginx所在网络名称
```
"Networks": {
"nginx_firstnet": {
```
9. 执行 docker network inspect nginx_firstnet 来确定一些网络信息:
```
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.20.0.0/16"
}
]
},
......
"Containers": {
"84e4e7a719e8a904255ebcb522ce73ff8d0f2340a42d12969cead432ecdf4b77": {
"Name": "nginx_nginx_1",
"EndpointID": "f7a35255526ed39931e018ad27c2bcc448840f77f4de9666baa4416c396c03a7",
"MacAddress": "02:42:ac:14:00:02",
"IPv4Address": "172.20.0.2/16",
"IPv6Address": ""
},
"e390b8cbe5075efed7fb834acd74fe7ae84cc685249362b4802abb1e626fc909": {
"Name": "frps_server_1",
"EndpointID": "04f759a5e894e9286720946763b123f805c76d869697113e83f53e516ed75c4b",
"MacAddress": "02:42:ac:14:00:03",
"IPv4Address": "172.20.0.3/16",
"IPv6Address": ""
}
},
```
可以看到现有的网段和网络中已有实例的IP。我们可以据此规划gitea实例的IP。
10. 根据上述两点网络相关的信息修改gitea的docker-compose文件中的对应部分并指定固定IP。
11. 将需要nginx代理的应用设置的固定IP填入之前的gitea.conf。
12. 重启nginx的docker容器。
问题发现重启失败。查看nginx的日志
- 首先是错误unknown directive "server"
[root@ngork logs]# tail -20 error.log
2021/10/29 14:01:25 [emerg] 7#7: unknown directive "?server" in /etc/nginx/conf.d/gitwoyue.conf:1
在开发环境(windows)编码保存为简体中文936解决。原为utf-8。其实这很奇怪与一般的认知是相反的。
- 然后是open() "/etc/letsencrypt/options-ssl-nginx.conf" failed (2: No such file or directory) in /etc/nginx/conf.d/gitwoyue.conf:22
注释掉即可。
13. 启动gitea的docker-compose
`docker-compose up -d`
14. 访问网站。初始化
例如git.woyue.org。
这里注意参考用到的compose文件确认用户名是否需要修改默认git
另外需要创建一个空的数据库。默认名是gitea。
## 使用说明
- 配置文件在:/srv/gitea/gitea/gitea/conf下的app.ini
- 邮件smtp服务器要带端口号通常是25
- 注意对于大项目的首次push有可能上传请求体大小超出Nginx限制。注意相关配置。参考https://blog.csdn.net/yedajiang44/article/details/99294216
## 测试环境
* CentOS Linux release 7.3.1611 (Core)
```
```