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.

De59527d0dd215a92d14a5df5df22aa8?s=128

Daniel Widerin

October 11, 2016
Tweet

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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)
  6. 9.
  7. 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
  8. 11.
  9. 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>
  10. 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
  11. 14.
  12. 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.
  13. 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
  14. 18.
  15. 19.
  16. 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
  17. 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
  18. 24.
  19. 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
  20. 26.
  21. 27.
  22. 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
  23. 29.