setup drone server

This commit is contained in:
Nebel 2022-12-26 22:56:37 +09:00
parent 98a9a88740
commit 5f0d0cb503
6 changed files with 60 additions and 2 deletions

6
.env.example Normal file
View file

@ -0,0 +1,6 @@
DRONE_GITEA_SERVER=https://git.fogtype.com/
DRONE_GITEA_CLIENT_ID=
DRONE_GITEA_CLIENT_SECRET=
DRONE_RPC_SECRET=
DRONE_SERVER_HOST=gamma.fogtype.com
DRONE_SERVER_PROTO=https

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.env

View file

@ -1,12 +1,36 @@
# γ
[git.fogtype.com](https://git.fogtype.com/) 用 Drone Server & Runner
## Setup
```sh
sudo apt install ansible docker-ce
ansible-playbook setup.yml
docker context create --docker=host=ssh://ubuntu@beta.fogtype.com beta
docker context create --docker=host=ssh://ubuntu@gamma.fogtype.com gamma
```
詳しい構成は [setup.yml](setup.yml) を参照
## Drone Server
Gitea への導入
: https://docs.drone.io/server/provider/gitea/
| 項目 | 値 |
| ---------------- | ------------------------------- |
| Application Name | gamma |
| Redirect URI | https://gamma.fogtype.com/login |
```bash
install -m 600 .env{.example,}
echo DRONE_RPC_SECRET=$(openssl rand -hex 16) >> .env
# .envファイルに適切な設定をする
```
### Deploy
```bash
docker context create --docker=host=ssh://ubuntu@gamma.fogtype.com gamma
docker context use gamma
docker compose up -d
```

19
compose.yml Normal file
View file

@ -0,0 +1,19 @@
services:
drone:
image: drone/drone:2
restart: unless-stopped
ports:
- "80:80"
- "443:443"
environment:
DRONE_TLS_AUTOCERT: "true"
DRONE_GITEA_SERVER: ${DRONE_GITEA_SERVER:?}
DRONE_GITEA_CLIENT_ID: ${DRONE_GITEA_CLIENT_ID:?}
DRONE_GITEA_CLIENT_SECRET: ${DRONE_GITEA_CLIENT_SECRET:?}
DRONE_RPC_SECRET: ${DRONE_RPC_SECRET:?}
DRONE_SERVER_HOST: ${DRONE_SERVER_HOST:?}
DRONE_SERVER_PROTO: ${DRONE_SERVER_PROTO:?}
volumes:
- drone_data_v2:/data
volumes:
drone_data_v2:

4
etc/docker/daemon.json Normal file
View file

@ -0,0 +1,4 @@
{
"live-restore": true,
"log-driver": "journald"
}

View file

@ -13,6 +13,10 @@
become: true
environment:
GCLOUD_API_KEY: "{{ grafana_gcloud_api_key }}"
- ansible.builtin.copy:
src: etc/docker/
dest: /etc/docker/
become: true
- ansible.builtin.apt_repository:
filename: docker
repo: deb [trusted=yes] https://download.docker.com/linux/ubuntu jammy stable