服務器資訊
droneci server 192.168.1.10
droneci runner 192.168.1.17
gitlab設定新增一組application
把applicaton ID和Secret記錄起來
Callback URL是droneCi的網址
server佈署腳本需照自已的設定修改
docker-compose.yml
services: drone-server: container_name: drone-server image: drone/drone:latest ports: - 8081:80 volumes: - ./:/data restart: always environment: - DRONE_SERVER_HOST=${DRONE_SERVER_HOST} - DRONE_SERVER_PROTO=${DRONE_SERVER_PROTO} - DRONE_RPC_SECRET=${DRONE_RPC_SECRET} #開啟runner - DRONE_AGENTS_ENABLED=true #關閉runner(單機模式) #- DRONE_AGENTS_DISABLED=true #- DRONE_RUNNER_CAPACITY=3 # 開啟日誌 - DRONE_LOGS_TRACE=true # Drone 與 GitHub 和 GitLab 一起使用,您需要運行兩個 Drone 服務器實例 ### Gitlab Config - DRONE_GITLAB_SERVER=https://gitlab.itnotetk.com - DRONE_GITLAB_CLIENT_ID=${DRONE_GITLAB_CLIENT_ID} - DRONE_GITLAB_CLIENT_SECRET=${DRONE_GITLAB_CLIENT_SECRET} - DRONE_LOGS_PRETTY=true # 開啟log區分顏色 - DRONE_LOGS_COLOR=true # 開啟debug mod #- DRONE_DEBUG=true ### Gitea #- DRONE_GITEA_CLIENT_ID #- DRONE_GITEA_CLIENT_SECRET ### GitHub Config #- DRONE_GITHUB_SERVER=https://github.com #- DRONE_GITHUB_CLIENT_ID=${DRONE_GITHUB_CLIENT_ID} #- DRONE_GITHUB_CLIENT_SECRET=${DRONE_GITHUB_CLIENT_SECRET} #- DRONE_LOGS_PRETTY=true #- DRONE_LOGS_COLOR=true ### BITBUCKET Config #- DRONE_BITBUCKET_CLIENT_ID=<你的OAuth ID> # OAuth 的 Application ID #- DRONE_BITBUCKET_CLIENT_SECRET=<你的 OAuth Secret> # OAuth 的 Secret drone-agent: container_name: drone-agent image: drone/agent:latest restart: always depends_on: - drone-server volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - DRONE_RPC_SERVER=http://drone-server - DRONE_RPC_SECRET=${DRONE_RPC_SECRET} - DRONE_RUNNER_CAPACITY=3 - DRONE_LOGS_TRACE=true drone-runner: container_name: drone-runner image: drone/drone-runner-docker:latest restart: always depends_on: - drone-server volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - DRONE_RPC_PROTO=http # 如果直接使用本配置,这儿不需要改,如果部署到其他服务器,需要填server的域名 - DRONE_RPC_HOST=drone-server # server配置的DRONE_RPC_SECRET - DRONE_RPC_SECRET=${DRONE_RPC_SECRET} - DRONE_RUNNER_CAPACITY=3 - DRONE_RUNNER_NAME=drone-runner - DRONE_RPC_SKIP_VERIFY=true - DRONE_TMATE_ENABLED=true - DRONE_LOGS_TRACE=true #Optional string value. Sets the name of the runner - DRONE_RUNNER_NAME=dev_depoly
新增一個隱藏檔.env
RONE_SERVER_HOST=drone.itnotetk.com DRONE_SERVER_PROTO=https DRONE_RPC_SECRET=03d20f3fd943e68f01ea8df554a3ab92 #gitlab use DRONE_GITLAB_CLIENT_ID=填入gitlab產生的id DRONE_GITLAB_CLIENT_SECRET=填入gitlab產生的secret ###github use #DRONE_GITHUB_CLIENT_ID= #DRONE_GITHUB_CLIENT_SECRET=
docker-compose up -d
runner佈署腳本
docker-compose.yml
services: drone-runner: container_name: drone-runner image: drone/drone-runner-docker:latest restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - DRONE_RPC_PROTO=https - DRONE_RPC_HOST=drone.itnotetk.com - DRONE_RPC_SECRET=${DRONE_RPC_SECRET} - DRONE_RUNNER_CAPACITY=2 - DRONE_RUNNER_NAME=drone-runner2 - DRONE_RPC_SKIP_VERIFY=true - DRONE_TMATE_ENABLED=true
新增隱藏檔.env
DRONE_SERVER_HOST=drone.itnotetk.com DRONE_SERVER_PROTO=https DRONE_RPC_SECRET=03d20f3fd943e68f01ea8df554a3ab92 #gitlab use DRONE_GITLAB_CLIENT_ID=填入gitlab產生的id DRONE_GITLAB_CLIENT_SECRET=填入gitlab產生的secret
開啟server的ui http://192.168.1.10:8081/
登入需要輸入gitlab的帳密
將gitlab上面的repo同步至droneci
在go-server底下新增編寫好的 .drone.yml 腳本
修改要編譯的檔案後 git push
droneci就會執行pipeline