Drone + Github

创建一个Github OAuth APP

Settings > Developer settings > OAuth Apps > New OAuth App

创建共享秘钥

openssl rand -hex 16

拉取Docker drone镜像

docker pull drone/drone:1
docker pull drone/drone-runner-docker:1

配置docker-compose.yml

Linux需安装Docker Compose, Windows和Mac集成了Compose.

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

配置drone和drone-runner

version: '3'

services:
  drone-server:
    image: drone/drone:1
    ports:
      - 8081:80
    volumes:
      - ./drone:/data
    restart: always
    environment:
      - DRONE_SERVER_HOST=${DRONE_SERVER_HOST}
      - DRONE_SERVER_PROTO=${DRONE_SERVER_PROTO}
      - DRONE_RPC_SECRET=${DRONE_RPC_SECRET}

      # GitHub Config
      - DRONE_GITHUB_SERVER=https://github.com
      - DRONE_GITHUB_CLIENT_ID=${DRONE_GITHUB_CLIENT_ID}
      - DRONE_GITHUB_CLIENT_SECRET=${DRONE_GITHUB_CLIENT_SECRET}

      - DRONE_LOGS_PRETTY=true
      - DRONE_LOGS_COLOR=true

  # runner for docker version
  drone-runner:
    image: drone/drone-runner-docker:1
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_RPC_HOST=${DRONE_RPC_HOST}
      - DRONE_RPC_PROTO=${DRONE_RPC_PROTO}
      - DRONE_RPC_SECRET=${DRONE_RPC_SECRET}
      - DRONE_RUNNER_CAPACITY=3

创建.env环境变量

DRONE_SERVER_HOST=drone.qwq.dog
DRONE_SERVER_PROTO=https
DRONE_RPC_SECRET=xxx

DRONE_GITHUB_CLIENT_ID=xxx
DRONE_GITHUB_CLIENT_SECRET=xxx

DRONE_RPC_HOST=drone-server
DRONE_RPC_PROTO=http

启动并访问

docker-compose -f ./docker-compose.yum up -d

外网域名访问

Nginx反向代理配置

server{
    listen 80;
    listen 443 ssl http2
    server name drone.qwq.dog
#PROXY-START/
location  ~* \.(php|jsp|cgi|asp|aspx)$
{
    proxy_pass http://127.0.0.1:8081;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
}
location /
{
    proxy_pass http://127.0.0.1:8081;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

    add_header X-Cache $upstream_cache_status;

    #Set Nginx Cache

        add_header Cache-Control no-cache;
    expires 12h;
}
#PROXY-END/
}

Drone + Gitea/Gogs

Last modification:May 28th, 2020 at 09:50 pm
如果觉得我的文章对你有用,请随意赞赏,感谢!