Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jenkins & Docker Integration.

Ash Wu
December 03, 2014

Jenkins & Docker Integration.

Integrate Jenkins and Docker, using docker to build QA environment.

Ash Wu

December 03, 2014
Tweet

More Decks by Ash Wu

Other Decks in Programming

Transcript

  1. CONTINUOUS INTEGRATION Continuous integration (CI) is the practice, in software

    engineering, of merging all developer working copies with a shared mainline several times a day. It was first named and proposed by Grady Booch in his method,[1] who did not advocate integrating several times a day. It was adopted as part of extreme programming (XP), which did advocate multiple integrations a day, perhaps as many as tens a day. The main aim of CI is to prevent integration problems, referred to as "integration hell" in early descriptions of XP. CI isn't universally accepted as an improvement over frequent integration, so it is important to distinguish between the two as there is disagreement about the virtues of each…… http://en.wikipedia.org/wiki/Continuous_integration
  2. •  有了測試,就不會修 A 壞 B •  出現過的 bug 不會再出現 • 

    重構、加新功能、修 bug 的時候更 有信心 •  QA 時間縮短,deploy 頻率增加
  3. JENKINS •  Since 2004 •  Open source •  Java • 

    Support CVS, SVN, Git, HG… •  LOTS of plugins. 
  4. JENKINS BUILD TRIGGER 1. 手動 2. 有人 push master branch 3. 有人發 github

    pull request https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin
  5. CI OF KKTIX •  KKTIX 是用 Rails & Go 搭建

    •  有單元測試,也有整合測試 •  測試時會用到許多資源與服務
  6. DOCKER USE CASE 1.  開發環境 (http://www.fig.sh/) 2.  Open source project

    •  https://github.com/stucki/docker-cyanogenmod •  https://github.com/discourse/discourse_docker 3.  伺服器部署 •  https://coreos.com/ •  http://aws.amazon.com/ecs/ •  https://cloud.google.com/container-engine/
  7. DOCKER BASICS •  Image (frozen app) •  Container •  1

    image > multiple running container •  No init •  Process finished, container stopped.
  8. HOW TO CREATE DOCKER IMAGE •  docker pull 取得 image

    > docker run 某個 image 做修改 > docker commit 成新的 image (https://registry.hub.docker.com) •  寫 Dockerfile 執行 docker build (FROM ubuntu/12:04)
  9. DOCKER CONTAINER •  expose •  add / copy •  volume

    •  attach / detach •  pause / unpause •  link between containers
  10. QA ENVIRONMENT •  使用 volume 讓 container 和 host 共享

    目錄 •  Nginx 透過 subdomain 判斷連到哪一個 container 的 document root •  聽 port 的都改成聽 unix domain socket 免除處理 port 的困擾 •  Port 轉 socket 可用 socat ( http://www.dest-unreach.org/socat/ )
  11. CONCLUSION •  如果還沒開始寫測試,趕快寫。現 在,馬上。 •  有寫測試還沒有 CI, 可以試著用用 看 CI

    •  已經有 run CI 的可以導入 Docker 讓測試環境單純化,做平行化測試