Docker中安装Drone(基于Gitea)
参考地址:https://docs.drone.io/server/provider/gitea/
1.在Gitea中创建OAuth应用。
2.创建共享密钥
注意:共享密钥的作用是用来和Drone Runner通信,和Gitea没有关系,但是在使用Docker命令创建的时候需要以参数的形式写入进去。
openssl rand -hex 16
3.创建server。
1.下载镜像
docker pull drone/drone:2
2.运行
docker run \ --volume=/mnt/docker/drone:/data \ --env=DRONE_GITEA_SERVER=http://192.168.182.128:3000 \ --env=DRONE_GITEA_CLIENT_ID=bdedfb68-1342-4ea4-8413-15dc555b3669 \ --env=DRONE_GITEA_CLIENT_SECRET=gto_df7fulp6tkq6hrqokvazsm6jlct6d7b4lxqjh3p7zo2z5ylvglca \ --env=DRONE_RPC_SECRET=e845aebc67571153ccac86dd54805ff3 \ --env=DRONE_SERVER_HOST=192.168.182.128 \ --env=DRONE_SERVER_PROTO=http \ --env=DRONE_GIT_ALWAYS_AUTH=true \ --env=DRONE_GIT_USERNAME=fanqi \ --env=DRONE_GIT_PASSWORD=qwer1234 \ --env=DRONE_USER_CREATE=username:fanqi,admin:true \ --publish=80:80 \ --publish=443:443 \ --restart=always \ --detach=true \ --name=drone-server \ drone/drone:2
4.创建 runner
参考地址:https://docs.drone.io/runner/docker/installation/linux/
1.下载镜像
docker pull drone/drone-runner-docker:1
2.运行
注意:我的gitea占用了3000端口,注意修改映射端口防止冲突
docker run --detach \ --volume=/var/run/docker.sock:/var/run/docker.sock \ --env=DRONE_RPC_PROTO=http \ --env=DRONE_RPC_HOST=192.168.182.128 \ --env=DRONE_RPC_SECRET=e845aebc67571153ccac86dd54805ff3 \ --env=DRONE_RUNNER_CAPACITY=2 \ --env=DRONE_RUNNER_NAME=drone-runner-docker \ --publish=3000:3000 \ --restart=always \ --name=drone-runner-docker \ drone/drone-runner-docker:1
**【3和4可以使用docker compose进行部署】**
version: '3' services: drone-server: restart: always image: drone/drone:2 ports: - "80:80" - "443:443" volumes: - /mnt/docker/drone:/var/lib/drone/ - /mnt/docker/drone/data:/data/ environment: - DRONE_GITEA_SERVER=http://192.168.182.128:3000 - DRONE_GITEA_CLIENT_ID=bdedfb68-1342-4ea4-8413-15dc555b3669 - DRONE_GITEA_CLIENT_SECRET=gto_df7fulp6tkq6hrqokvazsm6jlct6d7b4lxqjh3p7zo2z5ylvglca - DRONE_SERVER_HOST=192.168.182.128 - DRONE_SERVER_PROTO=http - DRONE_RPC_SECRET=e845aebc67571153ccac86dd54805ff3 - DRONE_GIT_ALWAYS_AUTH=true - DRONE_GIT_USERNAME=fanqi - DRONE_GIT_PASSWORD=qwer1234 - DRONE_USER_CREATE=username:fanqi,admin:true drone-runner-docker: restart: always image: drone/drone-runner-docker:1 ports: - "3000:3000" volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - DRONE_RPC_PROTO=http - DRONE_RPC_HOST=drone-server - DRONE_RPC_SECRET=e845aebc67571153ccac86dd54805ff3 - DRONE_RUNNER_NAME=drone-runner-docker - DRONE_RUNNER_CAPACITY=2
5.访问