## 安装

### 1.安装 Docker

1.允许使用 https
```
$ apt install apt-transport-https ca-certificates
```

2.添加 Docker 的官方 GPG 密钥
```
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```

3.添加 Docker 官方库
```
$ sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```

4.安装最新版 Docker
```
$ sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
$ systemctl status docker
$ systemctl enable docker
$ docker version
```

5.安装 docker-compose
```
$ sudo curl -L "https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
$ docker-compose -v
```

### 2.拉取镜像
```
$ docker pull drone/drone:2
$ docker pull drone/drone-runner-docker:1
```

### 3.启动 drone
```
$ docker run \
  --volume=/var/lib/drone:/data \
  --env=DRONE_AGENTS_ENABLED=true \
  --env=DRONE_GOGS_SERVER=http://git.daoguyujia.com \
  --env=DRONE_RPC_SECRET=xy7eZPO%z7KV8S2A \
  --env=DRONE_SERVER_HOST=drone.daoguyujia.com \
  --env=DRONE_SERVER_PROTO=http \
  --env=DRONE_USER_CREATE=username:gogs,machine:false,admin:true,token:55f24eb3d61ef6ac5e83d550178638dc \
  --env=DRONE_COOKIE_SECRET=91e9fe6277f14e0e8831430bcc7663ab \
  --publish=4001:80 \
  --publish=4443:443 \
  --restart=always \
  --detach=true \
  --name=drone2 \
  drone/drone:2
```
### 启动 drone-runner
```
docker run --detach \
  --volume=/var/run/docker.sock:/var/run/docker.sock \
  --env=DRONE_RPC_PROTO=http \
  --env=DRONE_RPC_HOST=drone.daoguyujia.com \
  --env=DRONE_RPC_SECRET=xy7eZPO%z7KV8S2A \
  --env=DRONE_RUNNER_CAPACITY=2 \
  --env=DRONE_RUNNER_NAME=drone-runner \
  --publish=4002:3000 \
  --restart=always \
  --name=drone-runner \
  drone/drone-runner-docker:1
```

开放安全组端口：4000,4001,4002,4443,10022