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

Continuous integration with gitlab and docker

Continuous integration with gitlab and docker

Slides for a presentation I gave at VlbgWebDev 10/2016.
To reduce risks on conference wifi i've embedded videos.
Sorry but these are not visible on speaker deck.

Daniel Widerin

October 11, 2016
Tweet

Other Decks in Programming

Transcript

  1. CONTINUOUS INTEGRATION WITH GITLAB AND DOCKER VLBG WEBDEV 10/16

  2. DANIEL WIDERIN HEAD OF 
 DEVELOPMENT AND TEST CORPORATE IT


    ZUMTOBEL GROUP AG
  3. WHAT IS
 CONTINUOUS INTEGRATION? The Management CI/CD WITH GITLAB AND

    DOCKER
  4. CI/CD WITH GITLAB AND DOCKER CONTINUOUS INTEGRATION REQUIREMENTS AND BEST

    PRACTICES ▸ Use a code repository / version control system ▸ Use a branching model ▸ Commit early - commit often ▸ Automate the build, tests and deployments ▸ Use an integration machine ▸ Use continuous feedback mechanisms
  5. CI/CD WITH GITLAB AND DOCKER GITLAB ▸ GitLab started as

    on-premise GitHub ▸ Full featured webgui for git version control system ▸ Integrated very powerful CI environment ▸ Workflows / Permissions supported 
 out-of-the-box ▸ http://about.gitlab.com
  6. CI/CD WITH GITLAB AND DOCKER DOCKER ▸ Allows you to

    package your application into a standardized unit for software development ▸ Often called "lightweight" virtualization approach. ▸ very fast growing and wide spreaded in open source community ▸ insanely great! ▸ http://docker.io
  7. CI/CD WITH GITLAB AND DOCKER ARCHITECTURE ▸ GitLab server owns

    code and acts as coordinator ▸ GitLab CI runners connect to the coordinator using a REST api ▸ Redis job queue consumed by runners, execute it and upload artifacts back to coordinator. ▸ The more (powerful) runners you connect, the more builds you can run in parallel
  8. CI/CD WITH GITLAB AND DOCKER EXECUTORS ▸ GitLab runners have

    multiple executors: ▸ shell run build locally ▸ docker run build using Docker container ▸ ssh run build remotely with SSH ▸ parallels run build using Parallels VM ▸ virtualbox run build using VirtualBox VM ▸ docker+machine like docker, but uses auto-scaled docker machines ▸ kubernetes (experimental)
  9. SETUP

  10. CI/CD WITH GITLAB AND DOCKER SETUP YOUR CI-PIPELINE ▸ Code

    hosted on gitlab.com or your on-premise gitlab installation ▸ add a .gitlab-ci.yml file
  11. None
  12. CI/CD WITH GITLAB AND DOCKER SETUP YOUR CI-PIPELINE ▸ Code

    hosted on gitlab.com or your on-premise gitlab installation ▸ add a .gitlab-ci.yml file ▸ connect a gitlab ci runner - use following command to install on macOS with homebrew:
 brew install gitlab-ci-multi-runner 
 --without-docker
 gitlab-runner register 
 --url https://gitlab.com 
 --token <token>
  13. CI/CD WITH GITLAB AND DOCKER SETUP YOUR CI-PIPELINE ▸ Code

    hosted on gitlab.com or your on-premise gitlab installation ▸ add a .gitlab-ci.yml file ▸ connect a gitlab ci runner - use following command to install on macOS with homebrew:
 brew install gitlab-ci-multi-runner 
 --without-docker
 gitlab-runner register 
 --url https://gitlab.com 
 --token <token> ▸ start the runner gitlab-runner
 gitlab-runner install
 gitlab-runner start
  14. None
  15. CI/CD WITH GITLAB AND DOCKER SETUP YOUR CI-PIPELINE ▸ Code

    hosted on gitlab.com or your on-premise gitlab installation ▸ add a .gitlab-ci.yml file ▸ connect a gitlab ci runner - use following command to install on macOS with homebrew:
 brew install gitlab-ci-multi-runner 
 --without-docker
 gitlab-runner register 
 --url https://gitlab.com 
 --token <token> ▸ start the runner gitlab-runner
 gitlab-runner install
 gitlab-runner start ▸ commit and push to remote to trigger ci pipeline.
  16. PYRAMID DEMO

  17. CI/CD WITH GITLAB AND DOCKER PYRAMID TUTORIAL APP ▸ Found

    in https://gitlab.com/widerin/vlbg-webdev-1016/ tree/pyramid ▸ Just output the foo in route http://localhost:8080/hello/foo ▸ pytest covered ▸ build and tested on gitlab in docker
  18. None
  19. None
  20. FULLY DOCKERIZED APPLICATIONS CONNECT SERVICES IN TEST PIPELINE

  21. CI/CD WITH GITLAB AND DOCKER HOW TO CONNECT SERVICES? ▸

    your application requires a database like postgresql ▸ your application requires a message queue like redis or rabbitmq ▸ your application requires a index engine like solr or elasticsearch ▸ very time consuming test setup in default ci-scenarios APPLICATION DATABASE INDEX
  22. FLASK DEMO

  23. CI/CD WITH GITLAB AND DOCKER FLASK TUTORIAL PING APP V1

    ▸ Found in https://gitlab.com/widerin/vlbg-webdev-1016/ tree/master/example-1 ▸ Ping application responses with "pong!"
 http://localhost:5000/ping ▸ pytest covered ▸ build and tested on gitlab in docker
  24. None
  25. CI/CD WITH GITLAB AND DOCKER FLASK TUTORIAL PING APP V2

    ▸ Found in https://gitlab.com/widerin/vlbg-webdev-1016/ tree/master/example-2 ▸ Ping application responses with "pong!" and outputs the number of pings you sent to it.
 http://localhost:5000/ping ▸ redis as persistence layer ▸ pytest covered ▸ build and tested on gitlab in docker
  26. None
  27. None
  28. CI/CD WITH GITLAB AND DOCKER NATIVE BUILDS IN DOCKER ▸

    Use your favourite linux docker image ▸ build within the image ▸ compile your application for your production servers in same linux distribution ▸ use caches for node_modules/, .m2/repository, ... ▸ you can build your own docker base and/or test images
  29. None
  30. QUESTIONS? TOPICS FOR NEXT SESSIONS? CI/CD WITH GITLAB AND DOCKER

  31. THANK YOU all examples can be found here:
 https://gitlab.com/widerin/vlbg-webdev-1016 http://widerin.net