Slide 1

Slide 1 text

CONTINUOUS INTEGRATION WITH GITLAB AND DOCKER VLBG WEBDEV 10/16

Slide 2

Slide 2 text

DANIEL WIDERIN HEAD OF 
 DEVELOPMENT AND TEST CORPORATE IT
 ZUMTOBEL GROUP AG

Slide 3

Slide 3 text

WHAT IS
 CONTINUOUS INTEGRATION? The Management CI/CD WITH GITLAB AND DOCKER

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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)

Slide 9

Slide 9 text

SETUP

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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 ▸ start the runner gitlab-runner
 gitlab-runner install
 gitlab-runner start

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

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 ▸ start the runner gitlab-runner
 gitlab-runner install
 gitlab-runner start ▸ commit and push to remote to trigger ci pipeline.

Slide 16

Slide 16 text

PYRAMID DEMO

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

FULLY DOCKERIZED APPLICATIONS CONNECT SERVICES IN TEST PIPELINE

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

FLASK DEMO

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

QUESTIONS? TOPICS FOR NEXT SESSIONS? CI/CD WITH GITLAB AND DOCKER

Slide 31

Slide 31 text

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