持續集成、持續交付、持續部署

一、術語解釋
在軟件開發領域,經常提到持續繼承(Continuous Integration,CI)、持續交付(Continuous Delivery,CD)和持續部署(Continuous Deployment)等術語。

持續集成
continuous integration (CI) is the practice of merging all developer working copies to a shared mainline several times a day.
即持續集成是指開發階段,對項目進行持續性自動化編譯、測試,以達到控制代碼質量的手段。核心是確保新增的代碼能夠與主幹代碼正確的集成,持續集成是一種軟件開發實踐。

持續交付
Continuous delivery (CD or CDE) is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time and, when releasing the software, doing so manually.
持續交付是在部署到生產環境之前,加了一個業務判斷,決定是否交付給客戶,然後一鍵部署到生產環境,核心是交付的產物而非代碼,是一種使得軟件在較短的循環中可靠發佈的軟件工程方法。

持續部署
Continuous deployment (CD) is a software engineering approach in which software functionalities are delivered frequently through automated deployments.
即通過自動化部署的手段將軟件功能頻繁的進行交付。

目前項目上線,必然會使用到持續集成工具,如Jenkins,walle等,當然,目前公司使用比較多的是Jenkins(上家公司就是),但現在的公司使用的是walle(瓦力),所以就研究了一下,在此記錄一下安裝使用。

二、walle安裝問題說明

官方安裝說明
github地址

1 python編輯安裝及其擴展安裝
2 pip安裝及python版本對應
3 walle環境mysql配置(最好是5.7及以上版本,否則migration文件執行會報錯,datetime 默認值問題)
4 搭建過程中核心文件admin.sh (init start),會遇到很多問題(比如flask擴展,python虛擬環境等),都可以google解決
5 nginx server配置,參考官方文檔和runtime.log詳細信息,基本沒問題,我的walle.conf配置如下

upstream webservers {
    server 0.0.0.0:5000 weight=1; # 負載設置
}

server
{
    listen 80;
    server_name  admin.walle-web.io; # 域名設置
    access_log   /usr/local/nginx/logs/walle.log;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ /index.html;
        add_header access-control-allow-origin *;
        root /var/www/walle/fe;
    }

    location ^~ /api/ {
        add_header access-control-allow-origin *;
        proxy_pass http://webservers;
        proxy_set_header  X-Forwarded-Host $host:$server_port;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header    Origin        $host:$server_port;
        proxy_set_header    Referer       $host:$server_port;
    }

    location ^~ /socket.io/ {
        add_header access-control-allow-origin *;
        proxy_pass http://webservers;
        proxy_set_header  X-Forwarded-Host $host:$server_port;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header    Origin        $host:$server_port;
        proxy_set_header    Referer       $host:$server_port;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        # WebScoket Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

7 用各個賬戶登錄看看,最後用所有者:[email protected] \ Walle123來登錄並創建發佈項目
8 遠程目標機器免密碼登錄失敗,把walle部署機器的id_rsa.pub拷貝到目標發佈機器的authorized_keys文件中
9 創建項目中的“目標集羣部署路徑” 和 “目標集羣部署倉庫” 是指定的某個代碼發佈目錄,注意,這個目錄不需要提前創建,比如要發佈的目錄爲/opt/projects/www, 則機器上的目錄只到/opt/projects/,否則會報mv: cannot overwrite directory ‘/opt/projects/deploy’ with non-directory
10 項目發佈模板,可以定製很多(前置,後置)如,停服,啓服等
11 代碼一旦成功部署完成後,即可配置nginx訪問站點

三、walle系統圖例
1 環境列表
在這裏插入圖片描述
2 服務器管理
在這裏插入圖片描述
3 創建項目
在這裏插入圖片描述

4 項目列表
在這裏插入圖片描述
歡迎一起學習交流,如有侵權,請聯繫刪除!

參考文檔
1 http://www.walle-web.io/
2 https://jenkins.io/zh/
3 https://github.com/meolu/walle-web

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章