diff --git a/.env b/.env index f02898a..e7e146f 100644 --- a/.env +++ b/.env @@ -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_CLIENT_ID=da1cdbdd-a50d-4367-80d9-a8fdff8c652f DRONE_GITEA_CLIENT_SECRET=ftJDp0UdFgutif7K3XuFYZKAXCLaHZxKA-psdyS_LkE= @@ -5,6 +12,7 @@ DRONE_RPC_SECRET=a1cf994eee95899f31f296c25d8310f0 DRONE_SERVER_HOST=drone.07fi.net DRONE_SERVER_PROTO=https +#Drone Runner DRONE_RPC_PROTO=http DRONE_RPC_HOST=drone.07fi.net:8000 DRONE_RUNNER_CAPACITY=2 diff --git a/README.md b/README.md index 30489bd..2b00ebc 100644 --- a/README.md +++ b/README.md @@ -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 -### 启动 Gitea +## Lets get started! +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 -``` -### 停止 Gitea -```bash -./run.sh gitea stop // or cd gitea && docker-compose down +#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 ``` -### 创建 OAuth 应用 -> 参考链接, 参考 `Step 1:Preparation`部分 -[Visit](https://docs.drone.io/server/provider/gitea/) -### Create a Shared Secret +In order to configure drone we must run the cluster without drone Oauth configuration so start up with: ``` -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 ``` -``` \ No newline at end of file +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! diff --git a/docker-compose.yml b/docker-compose.yml index 3df25a5..48105d5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock:ro environment: - - DEFAULT_EMAIL=07fi123@gmail.com + - DEFAULT_EMAIL=${07fi123@gmail.com} depends_on: - gitea - drone @@ -41,8 +41,8 @@ services: - ./gitea/data:/data environment: - VIRTUAL_PORT=3000 - - VIRTUAL_HOST=git.07fi.net - - LETSENCRYPT_HOST=git.07fi.net + - VIRTUAL_HOST=${GITEA_HOST} + - LETSENCRYPT_HOST=${GITEA_HOST} - USER_UID=1000 - USER_GID=1000 - TZ=America/Chicago @@ -76,8 +76,8 @@ services: - DRONE_DATABASE_DATASOURCE=/var/lib/drone/database.sqlite - DRONE_DATABASE_DRIVER=sqlite3 - TZ=America/Chicago - - VIRTUAL_HOST=drone.07fi.net - - LETSENCRYPT_HOST=drone.07fi.net + - VIRTUAL_HOST=${DRONE_SERVER_HOST} + - LETSENCRYPT_HOST=${DRONE_SERVER_HOST} drone-runner: image: drone/drone-runner-docker:1 diff --git a/example.env b/example.env new file mode 100644 index 0000000..15f7e89 --- /dev/null +++ b/example.env @@ -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 \ No newline at end of file