This commit is contained in:
Unknown 2020-03-25 13:45:07 -05:00
parent 2a3d254186
commit 60fa4967e0
4 changed files with 89 additions and 24 deletions

8
.env
View File

@ -1,3 +1,10 @@
#LetsEncrypt
LETSENCRYPT_DEFAULT_EMAIL=07fi123@gmail.com
#Gitea Server
GITEA_HOST=git.07fi.net
#Drone Server
DRONE_GITEA_SERVER=https://git.07fi.net DRONE_GITEA_SERVER=https://git.07fi.net
DRONE_GITEA_CLIENT_ID=da1cdbdd-a50d-4367-80d9-a8fdff8c652f DRONE_GITEA_CLIENT_ID=da1cdbdd-a50d-4367-80d9-a8fdff8c652f
DRONE_GITEA_CLIENT_SECRET=ftJDp0UdFgutif7K3XuFYZKAXCLaHZxKA-psdyS_LkE= DRONE_GITEA_CLIENT_SECRET=ftJDp0UdFgutif7K3XuFYZKAXCLaHZxKA-psdyS_LkE=
@ -5,6 +12,7 @@ DRONE_RPC_SECRET=a1cf994eee95899f31f296c25d8310f0
DRONE_SERVER_HOST=drone.07fi.net DRONE_SERVER_HOST=drone.07fi.net
DRONE_SERVER_PROTO=https DRONE_SERVER_PROTO=https
#Drone Runner
DRONE_RPC_PROTO=http DRONE_RPC_PROTO=http
DRONE_RPC_HOST=drone.07fi.net:8000 DRONE_RPC_HOST=drone.07fi.net:8000
DRONE_RUNNER_CAPACITY=2 DRONE_RUNNER_CAPACITY=2

View File

@ -1,30 +1,68 @@
# drone and gitea # Drone, Gitea, Ngnix, Lets Encrypt
*This repos was forked from github user [cnbattle](https://github.com/cnbattle/drone-gitea)*
> 需在公网上部署 I was inspired to host my own "gitlab/github clone" on my own hardware with docker.
This stack has most everything needed for someone to host something from their own box running docker.
Each docker service defined in the `docker-compose.yml` file has a specific job to do.
# 使用 - Gitea: the git remote host (think github clone)
- Drone: Ci server / runner
- Nginx-proxy: reverse proxy for using one docker host while routing to many domain names.
- Letsencrypt companion: handles the renewal of ssl certs automagicaly!
## 管理 Gitea ## Lets get started!
### 启动 Gitea To get started clone down this repository. Observe the contents of `example.env`, this file is an example of the main configuration file for the docker hosts.
Each of these fields is required and may include differences in configuration depnding on the ending configuration. As writen `example.env` assumes that one would like to use every possible option.
Each section corisponds to the assciated `docker-compose` directive.
``` ```
./run.sh gitea start // or cd gitea && docker-compose up -d #LetsEncrypt
``` LETSENCRYPT_DEFAULT_EMAIL=youremail@example.com
### 停止 Gitea
```bash #Gitea Server
./run.sh gitea stop // or cd gitea && docker-compose down GITEA_HOST=gitea.example.com
#Drone Server
DRONE_GITEA_SERVER=https://gitea.example.com
DRONE_GITEA_CLIENT_ID=da1cdbdd-a50d-4367-80d9-a8fdff8c652f #Oauth application id from gitea
DRONE_GITEA_CLIENT_SECRET=ftJDp0UdFgutif7K3XuFYZKAXCLaHZxKA-psdyS_LkE= #Oauth application secret
DRONE_RPC_SECRET=a1cf994eee95899f31f296c25d8310f0 #Generated drone RPC secret
DRONE_SERVER_HOST=drone.example.com
DRONE_SERVER_PROTO=https
#Drone Runner
DRONE_RPC_PROTO=http
DRONE_RPC_HOST=drone.example.com:8000 #Set this to the box host to bypass the proxy
DRONE_RUNNER_CAPACITY=2
DRONE_RUNNER_NAME=drone-runner
``` ```
### 创建 OAuth 应用 In order to configure drone we must run the cluster without drone Oauth configuration so start up with:
> 参考链接, 参考 `Step 1Preparation`部分
[Visit](https://docs.drone.io/server/provider/gitea/)
### Create a Shared Secret
``` ```
openssl rand -hex 16 docker-compose up -d
``` ```
## edit `.env` file Notice that `DRONE_GITEA_CLIENT_ID` and `DRONE_GITEACLIENT_SECRET` will be need to be filled in after createing a Oauth application in gitea.
Drone has documentaion [here](https://docs.drone.io/server/provider/gitea/).
Follow the tutorial and edit the file with the correct values then restart the services. DONT FORGET TO SAVE!
## Run Drone Server
``` ```
``` docker-compose down && docker-compose up -d
```
That should do it, you now have a running remote repo / Ci! Happy codeing!
## Trouble Shooting
Althought this configuration should work for most people there are some gotchas that may trip some people up.
## Requirments
- A publicly reachable host on port 80 and 443, required by letsencrypt
- A Domain that is controled by a a DNS provider that supports DNSSEC, required by letsencrypt
- A docker host that can expose port 80 and 443 on the host, ngnx-proxy
- Unique dns sub domains for Drone and gitea.
## Help, It wont work with my configuration!
*Dont panic ! Remember the hitch hikers guide!*
This configuration may not meet the needs of people on networks that do not suport the above. Feel free to fork and hack away if that's the case ! If something just isn't lineing up drop us a Issue! We are happy to help!

View File

@ -20,7 +20,7 @@ services:
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
environment: environment:
- DEFAULT_EMAIL=07fi123@gmail.com - DEFAULT_EMAIL=${07fi123@gmail.com}
depends_on: depends_on:
- gitea - gitea
- drone - drone
@ -41,8 +41,8 @@ services:
- ./gitea/data:/data - ./gitea/data:/data
environment: environment:
- VIRTUAL_PORT=3000 - VIRTUAL_PORT=3000
- VIRTUAL_HOST=git.07fi.net - VIRTUAL_HOST=${GITEA_HOST}
- LETSENCRYPT_HOST=git.07fi.net - LETSENCRYPT_HOST=${GITEA_HOST}
- USER_UID=1000 - USER_UID=1000
- USER_GID=1000 - USER_GID=1000
- TZ=America/Chicago - TZ=America/Chicago
@ -76,8 +76,8 @@ services:
- DRONE_DATABASE_DATASOURCE=/var/lib/drone/database.sqlite - DRONE_DATABASE_DATASOURCE=/var/lib/drone/database.sqlite
- DRONE_DATABASE_DRIVER=sqlite3 - DRONE_DATABASE_DRIVER=sqlite3
- TZ=America/Chicago - TZ=America/Chicago
- VIRTUAL_HOST=drone.07fi.net - VIRTUAL_HOST=${DRONE_SERVER_HOST}
- LETSENCRYPT_HOST=drone.07fi.net - LETSENCRYPT_HOST=${DRONE_SERVER_HOST}
drone-runner: drone-runner:
image: drone/drone-runner-docker:1 image: drone/drone-runner-docker:1

19
example.env Normal file
View File

@ -0,0 +1,19 @@
#LetsEncrypt
LETSENCRYPT_DEFAULT_EMAIL=youremail@example.com
#Gitea Server
GITEA_HOST=gitea.example.com
#Drone Server
DRONE_GITEA_SERVER=https://gitea.example.com
DRONE_GITEA_CLIENT_ID=da1cdbdd-a50d-4367-80d9-a8fdff8c652f #Oauth application id from gitea
DRONE_GITEA_CLIENT_SECRET=ftJDp0UdFgutif7K3XuFYZKAXCLaHZxKA-psdyS_LkE= #Oauth application secret
DRONE_RPC_SECRET=a1cf994eee95899f31f296c25d8310f0 #Generated drone RPC secret
DRONE_SERVER_HOST=drone.example.com
DRONE_SERVER_PROTO=https
#Drone Runner
DRONE_RPC_PROTO=http
DRONE_RPC_HOST=drone.example.com:8000 #Set this to the box host to bypass the proxy
DRONE_RUNNER_CAPACITY=2
DRONE_RUNNER_NAME=drone-runner