GitLab 與 Drone

安裝 GitLab

mkdir GitLab && cd GitLab
curl https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml -O
docker-compose up

如果出現 ERROR: manifest for sameersbn/gitlab:13.0.7 not found:

把 docker-compose.yml 的gitlab image 版本改為

sameersbn/gitlab:latest

安裝好輸入 docker ps 確認

進入 localhost:10080

預設會先請你輸入密碼,使用者名稱為 root

之後也可輸入 email 創建 user,不過不會收到 email

如果想要忘記密碼等傳送email功能需要設定 SMTP server

Gitlab clone 專案 with access token

通常在部署主機上需要 clone 專案,但使用個人的 ssh key 權限過大,所以可以創建專案的 access token,之後如下 clone 專案。

安裝 Drone CI

這邊如果還沒綁定 domain,建議先把 localhost 的 GitLab 與等下會用的 drone 的 port 都用 ngrok 產生 domain ,這樣才能正常使用

1.先去新增 OAuth Application : http://localhost:10080/profile/applications

callback url 記得在最後面加上 /login

2.然後產生 share secret openssl rand -hex 16

3.新增 docker-compose.yml

這邊如果 GitLab 或 Drone 用 localhost ,之後再 gitLab 連結 drone 時會產生錯誤

Login Failed. Post "http://localhost:10080/oauth/token": dial tcp 127.0.0.1:10080: connect: connection refused`

之後連入 drone url 會自動導到 gitLab 連結 drone 畫面,點選 authorize 即會導入到 drone 頁面

4. 剛才看到 docker-compose 下方的 runner 為用來執行 pipeline的

Last updated

Was this helpful?