test drone
continuous-integration/drone/push Build encountered an error
Details
continuous-integration/drone/push Build encountered an error
Details
parent
99b1b18d26
commit
dd9d564e37
|
@ -0,0 +1,79 @@
|
|||
---
|
||||
title: "Drone部署和与gitea的集成"
|
||||
date: 2023-08-07T19:09:08+08:00
|
||||
|
||||
---
|
||||
|
||||
原本的博客是直接使用的非开发模式的hugo server,但随着博客内容增多,内存占用巨大,经历昨晚内存溢出至交换区使服务器超高磁盘IO,所有服务无响应后决定将静态页面直接由原有反向代理的nginx直接托管
|
||||
|
||||
为了便于专注创作,在gitea上引入drone CI来做简单的持续集成变得有所必要,毕竟每次提交后都要手动pull和构建远远不够优雅:D
|
||||
|
||||
本文记录drone CI的docker-compose 方式部署并与已经完成部署的gitea docker集成,官方文档不推荐此种方式部署,也不建议gitea和drone部署在一台服务器上(预算不足暂出此策)
|
||||
|
||||
首先需要在gitea上创建OAth2应用令牌并设置应用的重定向URL
|
||||
|
||||

|
||||
|
||||
生成用于Drone的server和runner间通信的通信密钥
|
||||
|
||||
```bash
|
||||
openssl rand -hex 16
|
||||
```
|
||||
|
||||
drone-server的docker-compose文件
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
drone-server:
|
||||
image: drone/drone:2.13.0
|
||||
container_name: drone-server
|
||||
restart: always
|
||||
ports:
|
||||
- "7500:80"
|
||||
volumes:
|
||||
- ./data:/data
|
||||
environment:
|
||||
- DRONE_GITEA_SERVER= Gitea 服务器地址,例如 https://gitea.inksoul.top。注意填写准确的 http(s) 协议,否则你会看到来自 Gitea 的错误报告:unsupported protocol scheme
|
||||
- DRONE_GITEA_CLIENT_ID=Gitea OAuth 客户端ID
|
||||
- DRONE_GITEA_CLIENT_SECRET=Gitea OAuth 客户端密钥
|
||||
- DRONE_RPC_SECRET=在准备工作中使用 openssl rand -hex 16 生成的共享密钥。这个密钥用于验证 Drone Server 和 Runner 之间的 RPC 连接。因此,在 Server 和 Runner 上都必须使用相同的密钥
|
||||
- DRONE_SERVER_HOST=访问 Drone 时所用的域名或 IP 地址。如果使用 IP 地址,还应该包含端口
|
||||
- DRONE_SERVER_PROTO=设置服务器的协议,使用:http 或 https。 默认为 https
|
||||
- DRONE_USER_CREATE=管理员配置,这里的管理员用户名是Git仓库的用户名,不一定是Git仓库的管理员,只要是Git仓库的用户即可,例如 username:inksoul,admin:true
|
||||
```
|
||||
|
||||
在完成域名解析绑定和nginx中反向代理设定后,就可以拉取容器并启用了
|
||||
|
||||
nignx反向代理则在官方文档中有指出
|
||||
|
||||
```conf
|
||||
location / {
|
||||
|
||||
proxy_pass http://localhost:port/;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_pass_request_headers on;
|
||||
}
|
||||
```
|
||||
|
||||
完成准备后即可运行启动drone-server
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
随后可以安装负责流水线的droen-runner
|
||||
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: blog-publish
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: inksoul/hugo-rsync
|
||||
volumes: #挂载数据卷
|
||||
- name: blog
|
||||
path: /data
|
||||
commands:
|
||||
- hugo
|
||||
- rsync -a --delete --exclude '.user.ini' public/ /data
|
||||
|
||||
volumes: #声明数据卷
|
||||
- name: blog
|
||||
host:
|
||||
path: /home/ubuntu/myWork/Blog/InkSoul/public
|
|
@ -0,0 +1 @@
|
|||
[](https://drone.inksoul.top/inksoul/InkSoul)
|
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
Loading…
Reference in New Issue