在Debian系統上進行GitLab的定制化開發,可以按照以下步驟進行:
安裝GitLab:
sudo apt update
sudo apt upgrade
sudo apt install curl openssh-server ca-certificates tzdata perl
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt install gitlab-ce
sudo vim /etc/gitlab/gitlab.rb
找到并修改以下內容:external_url 'http://your-gitlab-domain.com'
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
配置防火墻:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
配置SSL證書(可選但推薦):
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your-gitlab-domain.com
配置CI/CD流水線:
.gitlab-ci.yml 文件,定義CI/CD流程:stages:
- build
- test
- deploy
build:
stage: build
script:
- echo "Building the project"
test:
stage: test
script:
- echo "Testing the project"
deploy:
stage: deploy
script:
- echo "Deploying the project"
git add .gitlab-ci.yml
git commit -m "Add CI/CD pipeline"
git push origin master
然后在GitLab項目管理頁面點擊 Run Pipeline 按鈕觸發流水線。定制GitLab功能:
/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml 文件,修改 host 為你的IP或域名。重啟GitLab后,克隆地址將更新為新的地址。/etc/gitlab/gitlab.rb 文件,設置 nginx['listen_port'] 為你需要的端口。例如:nginx['listen_port'] = 8080
重啟GitLab服務以應用更改。.gitlab-ci.yml 中定義的任務:
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash
sudo apt install gitlab-ci-multi-runner
通過以上步驟,你可以在Debian系統上進行GitLab的定制化開發,并根據具體需求進行進一步的配置和優化。