---
# System prepended metadata

title: Drone 與 GitTea Docker-compose 整合安裝紀錄
tags: [docker-compose, Public, Documentation, Drone, GitTea]

---

---
title: 'Drone 與 GitTea Docker-compose 整合安裝紀錄'
disqus: hackmd
---

Drone 與 GitTea Docker-compose 整合安裝紀錄
===

## 索引

[TOC]

## 注意事項

## 前置準備工作
https://gitea.xihetang.com.tw/user/login
![](https://i.imgur.com/IkigJy8.png)

### 設定Oauth
![](https://i.imgur.com/uFvj1TX.png)
![](https://i.imgur.com/ata3AHI.png)

* 應用程式名稱: `drone`
* 重新導向 URI: `https://drone.xihetang.com.tw/login`

![](https://i.imgur.com/vQJ1Fwu.png)

* 客戶端 ID: `12085f9c-c216-47da-b31e-6677b81be28c`
* 客戶端密鑰: `WyRHW6HaFoaXt0B8a3hKiZzIKu3NT7RnO6A8BbuX9FzL`

### 產生Runner間連結所需的Shared Secret
```bash
root@ubuntu-s-2vcpu-4gb-sgp1-01:/opt/gitea# openssl rand -hex 16
a6186daa731c620a34f02a7462fa22e5
root@ubuntu-s-2vcpu-4gb-sgp1-01:/opt/gitea#
```

* `Shared Secret` : `a6186daa731c620a34f02a7462fa22e5`

## 安裝與設定流程

```yaml
root@ubuntu-s-2vcpu-4gb-sgp1-01:/opt/drone# cat docker-compose.yaml
version: '3.5'

services:
  drone-server:
    image: drone/drone:2
    expose:
      - 80
      - 443
    #ports:
    #  - 8000:80
    #  - 9000:443
    #networks:
    #  - drone
    volumes:
      - ./drone-data:/data
      #- /var/run/docker.sock:/var/run/docker.sock
    #env_file:
    #  - ./drone.env
    restart: always
    environment:
      # 反向代理
      - VIRTUAL_HOST=drone.xihetang.com.tw
      - VIRTUAL_PORT=80
      - VIRTUAL_PROTO=http
      - LETSENCRYPT_HOST=drone.xihetang.com.tw
      - LETSENCRYPT_EMAIL=service.xihetang@gmail.com
      # GitTea整合
      - DRONE_GITEA_SERVER=https://gitea.xihetang.com.tw
      - DRONE_GITEA_CLIENT_ID=12085f9c-c216-47da-b31e-6677b81be28c
      - DRONE_GITEA_CLIENT_SECRET=QRlOaN9aAodX3WO9WCXxgRAVZZvjdN6mdXG9PSsaWL6l
      # Runner 與 Server溝通
      - DRONE_RPC_SECRET=a6186daa731c620a34f02a7462fa22e5
      # Drone Server
      - DRONE_SERVER_HOST=drone.xihetang.com.tw
      - DRONE_SERVER_PROTO=http

  drone-runner-docker:
    image: drone/drone-runner-docker:1
    restart: always
    depends_on:
      - drone-server
    expose:
      - 3000
    #networks:
    #  - drone
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    #env_file:
    #  - ./drone.env
    environment:
      - DRONE_RPC_PROTO=https
      - DRONE_RPC_HOST=drone.xihetang.com.tw
      - DRONE_RPC_SECRET=a6186daa731c620a34f02a7462fa22e5
      - DRONE_RUNNER_CAPACITY=2
      - DRONE_RUNNER_NAME=local-runner
```


## Reference and FAQ

:::info
**Find this document incomplete?** Leave a comment!
:::

###### tags: `Public` `Drone` `GitTea` `docker-compose` `Documentation`
