Docker和CI

一、CICD和DevOps

前面已經瞭解了CI/CD,其實CI/CD已經存在多年了,只是最近軟件工程方面又提出了敏捷開發、DevOps,又把CI/CD炒火了。

那麼什麼是DevOps?DevOps和CI/CD有又什麼關係呢?

以下內容摘自https://en.wikipedia.org/wiki/DevOps

DevOps (a clipped compound of "development" and "operations") is a software development methodology that combines software development (Dev) with information technology operations (Ops). The goal of DevOps is to shorten the systems development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.

DevOps(是由"development" and "operations"兩個單詞合成)是一個軟件開發工程的方法論,它包含了軟件開發和IT操作(測試和部署)。DevOps的目標是在持續交付、修改、更新時,緊密結合業務,旨在縮短系統開發的生命週期。


Docker和CI/CD實戰


Docker和CI/CD實戰

我這裡為什麼提出DevOps呢?因為DevOps其實是一套方法論,涵蓋了我們將要說的CI/CD。從上圖可以看出,DevOps包含了以下內容:

  1. Coding – code development and review, source code management tools, code merging(代碼)
  2. Building – continuous integration tools, build status(構建)
  3. Testing – continuous testing tools that provide feedback on business risks(測試)
  4. Packaging – artifact repository, application pre-deployment staging(打包)
  5. Releasing – change management, release approvals, release automation(發版)
  6. Configuring – infrastructure configuration and management, infrastructure as code tools(發佈)
  7. Monitoring – applications performance monitoring, end-user experience(監控)

CI基本上包括了編碼、構建、測試、打包、發版。

CD基本上主要就是發佈。


二、CI/CD和Docker結合

結合Docker,我們可以快速實現CI/CD,當然有少不了版本管理和編譯工具。


Docker和CI/CD實戰

具體流程如下:


Docker和CI/CD實戰

流程解析:

  1. 開發人員提交代碼到代碼庫(Git Push)
  2. Jenkins從版本庫拉取最新代碼(Pull Code)
  3. Jenkins通過Maven進行構建打包(Build Package)
  4. 通過Docker將最新版本做成鏡像,並推算至鏡像倉庫(Push/Harbor)
  5. 測試環境直接拉取最新版本鏡像,並部署到測試環境(Pull/Docker Build)


分享到:


相關文章: