参考文章
https://docs.gitea.io/zh-cn/comparison/
https://github.com/go-gitea/gitea
https://www.drone.io/
https://blog.csdn.net/tergou/article/details/120322269
前言
本来是打算搞gitlab,结果发现最低2g内存的要求过高,就找到了gitea+drone
环境
gitea:1.16.5
drone:2
drone-runner-docker:linux-amd64
Gitea+Mysql对应Docker-compose脚本
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.16.5
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- DB_TYPE=mysql
- DB_HOST=db:3306
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD=gitea
restart: always
networks:
- gitea
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db:
image: mysql:8
restart: always
environment:
- MYSQL_ROOT_PASSWORD=gitea
- MYSQL_USER=gitea
- MYSQL_PASSWORD=gitea
- MYSQL_DATABASE=gitea
networks:
- gitea
volumes:
- ./mysql:/var/lib/mysql
这里的账户密码根据情况修改
docker-compose up -d
打开ip:3000端口
修改对应配置
设置 >> 应用 >> 创建OAuth2 应用
点击创建会自动生成客户端id和客户端密钥
生成共享密钥
openssl rand -hex 16
version: '3'
services:
drone-server:
image: drone/drone:2
ports:
- 9080:80
- 9443:443
volumes:
- /data/drone:/data
restart: always
environment:
- DRONE_GITEA_SERVER=http://192.168.0.108:9300
- DRONE_GITEA_CLIENT_ID=客户端id
- DRONE_GITEA_CLIENT_SECRET=客户端密钥
- DRONE_RPC_SECRET=共享密钥
- DRONE_SERVER_HOST=192.168.0.108:9080
- DRONE_SERVER_PROTO=http
- DRONE_USER_CREATE=username:root,admin:true
drone-docker-runner:
image: drone/drone-runner-docker:linux-amd64
ports:
- 9030:3000
restart: always
depends_on:
- fan-drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_RPC_PROTO=http
- DRONE_RPC_HOST=192.168.0.108:9080
- DRONE_RPC_SECRET=共享密钥和上面的相同
- DRONE_RUNNER_CAPACITY=2
- DRONE_RUNNER_NAME=fan-docker-runner-1
这里需要关闭防火墙或者开放端口 不然会无法访问或者oauth
还有就是在新版本会添加允许webhook的ip
这里参考
https://github.com/go-gitea/gitea/issues/18402
修改映射出来的gitea/conf/app.ini
添加
[webhook]
ALLOWED_HOST_LIST = 192.168.0.0/16