# Drone ## 关于Drone Dron是一个现代化的持续集成平台,它使用强大的云原生pipeline引擎自动化构建、测试和发布工作流。Drone 与多个源代码管理系统无缝集成,包括 GitHub、GitHubEnterprise、Bitbucket、GitLab和Gitea;**它的每个构建都在一个隔离的 Docker 容器中运行**;另外它也支持插件,可以使用你熟知的语言轻松的扩展它们。 ## 安装 ### 依赖安装 需要安装docker和docker-compose,参照上方安装方式即可 ### 安装Drone 安装参考: [Gitea | Drone](https://docs.drone.io/server/provider/gitea/ "Gitea | Drone") 此处同样采用docker-compose.yml的方式安装 ```sh version: '3' services: drone-server: restart: always image: drone/drone:2 ports: - "映射宿主机端口:80" volumes: - 宿主机挂载目录:/var/lib/drone/ - 宿主机挂载目录:/data/ environment: - DRONE_GITEA_SERVER=http://gitea服务器地址 # 支持http, https - DRONE_GITEA_CLIENT_ID=gitea生成的OAuth2客户端ID - DRONE_GITEA_CLIENT_SECRET=gitea生成的OAuth2客户端密钥 - DRONE_SERVER_HOST=drone服务器地址 - DRONE_SERVER_PROTO=http # 支持http, https - DRONE_RPC_SECRET=自定义的Drone与runner通信密钥 - DRONE_GIT_ALWAYS_AUTH=true - DRONE_GIT_USERNAME=部署账户的用户名 - DRONE_GIT_PASSWORD=部署账户的密码 - DRONE_USER_CREATE=username:你的管理员账户名,admin:true # 开启管理员账户 drone-runner-docker: restart: always image: drone/drone-runner-docker:1 ports: - "3000:3000" volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - DRONE_RPC_PROTO=http # 支持http, https - DRONE_RPC_HOST=drone-server - DRONE_RPC_SECRET=自定义的Drone与runner通信密钥 - DRONE_RUNNER_NAME=drone-runner-docker - DRONE_RUNNER_CAPACITY=2 ``` 其中需要将gitea的授权信息填写到上方yml文件中 Gitea个人中心的应用设置创建Gitea OAuth application ![Snipaste_2022-08-07_14-26-05.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e8bd24a1a7b64ba69cd3ef0c17e7b94b~tplv-k3u1fbpfcp-zoom-1.image) 点击创建后将秘钥妥善保管并替换到上面的docker-compose.yml ``` - DRONE_GITEA_CLIENT_ID=gitea生成的OAuth2客户端ID - DRONE_GITEA_CLIENT_SECRET=gitea生成的OAuth2客户端密钥 - DRONE_GIT_USERNAME=令牌名称 - DRONE_GIT_PASSWORD=令牌秘钥 ``` 生成Drone与runner通信密钥,并替换上面docker-compose.yml对应的字段 ``` openssl rand -hex 16 93b722f581830b9abf11345536b9ecfb ``` 启动drone ``` docker-compose up -d ``` ### 访问drone 访问:[http://drone-server-domain](http://server-ip:80/ "http://drone-server-domain") ![Snipaste_2022-08-07_14-40-12.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/73d3ce553c35476d918423a338ba6b16~tplv-k3u1fbpfcp-zoom-1.image) 授权 ![Snipaste_2022-08-07_15-46-05.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/938964948d1c41ce8a0bb8773c1d5625~tplv-k3u1fbpfcp-zoom-1.image) 填写登录信息 ![7e22dd46559947ada73cb5605487610e.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/6f0e14a98fe8497c873cedc3e51b325f~tplv-k3u1fbpfcp-zoom-1.image) 登录之后就可以看到刚刚我们gitea中的项目 ![Snipaste_2022-08-07_15-46-05.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/de472caa4831442ca8a62599eeee2260~tplv-k3u1fbpfcp-zoom-1.image) 在设置中激活 ![1659858792624.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/ae20cae45d054faea8b2669d825c4b6d~tplv-k3u1fbpfcp-zoom-1.image) 激活保存 ![1659858832731.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/aa502a9023644e9e9f82475b0481a077~tplv-k3u1fbpfcp-zoom-1.image)