SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
CI with Docker
Using Gitlab CI
Jörg Henning
@joerghenning
What is GitLab?
● Git based code hosting &
collaboration platform
● Similar to GitHub, Bitbucket
● Open source, freemium
● Hosted (free) or on premise
● Rails, PostGres, etc.
● Actively maintained
● https://about.gitlab.com/
Gitlab CI
● Integrated with Gitlab
● Similar to Travis, Codeship
● Integrated since 8.0
● Build scripts hosted in repo
● Distributed runners
● Git hooks
#gitlab-ci.yml
image: ruby:2.2
services:
- postgres:9.3
before_script:
- bundle install
test:
script:
- bundle exec rake spec
Gitlab CI Multi Runner
● https://gitlab.com/gitlab-
org/gitlab-ci-multi-runner
● Written in Go, single binary
● Linux, Windows, OSX
● Or as Docker container
● Multiple executors - Shell,
Docker, VirtualBox, SSH
● Distributed
● Even local
Runners
Gitlab Server
#41
#40
#42
runner
server-us.domain.com
runner
server-sg.domain.com
runner
joe-macbook
As Docker Service
# Start runner as container in daemon mode
docker run -d
--name gitlab-runner 
--restart always 
-v /srv/gitlab-runner/config:/etc/gitlab-runner  # runner config
-v /var/run/docker.sock:/var/run/docker.sock  # docker sock
gitlab/gitlab-runner:latest
# Register runner with CI Server
docker exec -it gitlab-runner gitlab-runner register
Note: User running this needs to be in group `docker`.
Host System
Runner Setup
docker.sock /usr/bin/docker
gitlab-runner #2539 #2540 #2541
spawns
Docker Engine
Docker Executor
● Custom images, services, cache,
artifacts (gitlab-ci.yml)
● Caching, artifacts
● Images, from Docker Hub,
private registry
● Services
● Persistent storage (volumes=)
#gitlab-ci.yml
image: jdoe/node-4
services:
- mongo:3.0
- redis:2.8
cache:
artifacts:
test:
script:
- npm test
Executor Config
● Executor type
● Name (only informative)
● URl of GitLab installation
● Registration token
● Env vars
● etc.
[[runners]]
name = "Road Runner"
url = "https://git.acme.org/ci"
token = "{{TOKEN}}"
executor = "docker"
environment = ["ENV=value"]
Executor Config (Runner)
● Default image (overridden in
gitlab-ci.yml)
● Default services (added to the
ones in .gitlab-ci.yml)
● Private registry for image,
services
● Privileged (“dockerception”)
● Volumes, caches (arbitrary stuff
from host - npm cache, etc.)
● Image whitelist, etc.
[[runners]]
executor = "docker"
[runners.docker]
image = "ruby:2.1"
privileged = false
volumes = ["/data"]
services = ["mysql", "redis:2.8"]
allowed_images = ["ruby:*"]
allowed_services = ["postgres:latest"]
Advanced
● Autoscaling (docker-machine)
● Auto cleanup
● Docker-in-Docker
Demo
#/srv/gitlab-runner/config/config.toml
concurrent = 1
[[runners]]
name = "demo"
url = "http://192.168.33.20/ci"
token = "0cedbafa816f5b80a496f47c4c2e1e"
executor = "docker"
environment = ["npm_config_cache=/cache/npm","MYSQL_ALLOW_EMPTY_PASSWORD=1"]
[runners.docker]
tls_verify = false
image = "debian:jessie"
privileged = false
disable_cache = false
volumes = ["/var/cache:/cache:rw","/home/vagrant/.ssh:/root/.ssh:ro"]
services = ["mysql"]

Más contenido relacionado

La actualidad más candente

Introduction to Gitlab
Introduction to GitlabIntroduction to Gitlab
Introduction to Gitlab
Julien Pivotto
 

La actualidad más candente (20)

Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
 
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
 
What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020
 
CI/CD with GitHub Actions
CI/CD with GitHub ActionsCI/CD with GitHub Actions
CI/CD with GitHub Actions
 
Default GitLab CI Pipeline - Auto DevOps
Default GitLab CI Pipeline - Auto DevOpsDefault GitLab CI Pipeline - Auto DevOps
Default GitLab CI Pipeline - Auto DevOps
 
Introduction to Gitlab
Introduction to GitlabIntroduction to Gitlab
Introduction to Gitlab
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
CI/CD
CI/CDCI/CD
CI/CD
 
GitLab.pptx
GitLab.pptxGitLab.pptx
GitLab.pptx
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Introducing GitLab (June 2018)
Introducing GitLab (June 2018)Introducing GitLab (June 2018)
Introducing GitLab (June 2018)
 
CI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOWCI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOW
 
Automation CICD
Automation CICDAutomation CICD
Automation CICD
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Optimize your CI/CD with GitLab and AWS
Optimize your CI/CD with GitLab and AWSOptimize your CI/CD with GitLab and AWS
Optimize your CI/CD with GitLab and AWS
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
 
Git
GitGit
Git
 

Similar a CI with Gitlab & Docker

Similar a CI with Gitlab & Docker (20)

Gitlab runner in aws
Gitlab runner in aws Gitlab runner in aws
Gitlab runner in aws
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 
Ruby microservices with Docker - Sergii Koba
Ruby microservices with Docker -  Sergii KobaRuby microservices with Docker -  Sergii Koba
Ruby microservices with Docker - Sergii Koba
 
It's a Breeze to develop Apache Airflow (Apache Con Berlin)
It's a Breeze to develop Apache Airflow (Apache Con Berlin)It's a Breeze to develop Apache Airflow (Apache Con Berlin)
It's a Breeze to develop Apache Airflow (Apache Con Berlin)
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
 
Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = Code
 
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
 
Powercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptxPowercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptx
 
Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD Webinar - Unbox GitLab CI/CD
Webinar - Unbox GitLab CI/CD
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and Docker
 
Deploy Multinode GitLab Runner in openSUSE 15.1 Instances with Ansible Automa...
Deploy Multinode GitLab Runner in openSUSE 15.1 Instances with Ansible Automa...Deploy Multinode GitLab Runner in openSUSE 15.1 Instances with Ansible Automa...
Deploy Multinode GitLab Runner in openSUSE 15.1 Instances with Ansible Automa...
 
[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive
 
Gocd – Kubernetes/Nomad Continuous Deployment
Gocd – Kubernetes/Nomad Continuous DeploymentGocd – Kubernetes/Nomad Continuous Deployment
Gocd – Kubernetes/Nomad Continuous Deployment
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration Toolbox
 
Docker Enterprise Workshop - Technical
Docker Enterprise Workshop - TechnicalDocker Enterprise Workshop - Technical
Docker Enterprise Workshop - Technical
 
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
Workshop : 45 minutes pour comprendre Docker avec Jérôme PetazzoniWorkshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
 
Introduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" EditionIntroduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" Edition
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIContinuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CI
 
Deliver Python Apps with Docker
Deliver Python Apps with DockerDeliver Python Apps with Docker
Deliver Python Apps with Docker
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

CI with Gitlab & Docker

  • 3. What is GitLab? ● Git based code hosting & collaboration platform ● Similar to GitHub, Bitbucket ● Open source, freemium ● Hosted (free) or on premise ● Rails, PostGres, etc. ● Actively maintained ● https://about.gitlab.com/
  • 4. Gitlab CI ● Integrated with Gitlab ● Similar to Travis, Codeship ● Integrated since 8.0 ● Build scripts hosted in repo ● Distributed runners ● Git hooks #gitlab-ci.yml image: ruby:2.2 services: - postgres:9.3 before_script: - bundle install test: script: - bundle exec rake spec
  • 5.
  • 6. Gitlab CI Multi Runner ● https://gitlab.com/gitlab- org/gitlab-ci-multi-runner ● Written in Go, single binary ● Linux, Windows, OSX ● Or as Docker container ● Multiple executors - Shell, Docker, VirtualBox, SSH
  • 7. ● Distributed ● Even local Runners Gitlab Server #41 #40 #42 runner server-us.domain.com runner server-sg.domain.com runner joe-macbook
  • 8. As Docker Service # Start runner as container in daemon mode docker run -d --name gitlab-runner --restart always -v /srv/gitlab-runner/config:/etc/gitlab-runner # runner config -v /var/run/docker.sock:/var/run/docker.sock # docker sock gitlab/gitlab-runner:latest # Register runner with CI Server docker exec -it gitlab-runner gitlab-runner register Note: User running this needs to be in group `docker`.
  • 9. Host System Runner Setup docker.sock /usr/bin/docker gitlab-runner #2539 #2540 #2541 spawns Docker Engine
  • 10. Docker Executor ● Custom images, services, cache, artifacts (gitlab-ci.yml) ● Caching, artifacts ● Images, from Docker Hub, private registry ● Services ● Persistent storage (volumes=) #gitlab-ci.yml image: jdoe/node-4 services: - mongo:3.0 - redis:2.8 cache: artifacts: test: script: - npm test
  • 11. Executor Config ● Executor type ● Name (only informative) ● URl of GitLab installation ● Registration token ● Env vars ● etc. [[runners]] name = "Road Runner" url = "https://git.acme.org/ci" token = "{{TOKEN}}" executor = "docker" environment = ["ENV=value"]
  • 12. Executor Config (Runner) ● Default image (overridden in gitlab-ci.yml) ● Default services (added to the ones in .gitlab-ci.yml) ● Private registry for image, services ● Privileged (“dockerception”) ● Volumes, caches (arbitrary stuff from host - npm cache, etc.) ● Image whitelist, etc. [[runners]] executor = "docker" [runners.docker] image = "ruby:2.1" privileged = false volumes = ["/data"] services = ["mysql", "redis:2.8"] allowed_images = ["ruby:*"] allowed_services = ["postgres:latest"]
  • 13. Advanced ● Autoscaling (docker-machine) ● Auto cleanup ● Docker-in-Docker
  • 14. Demo
  • 15. #/srv/gitlab-runner/config/config.toml concurrent = 1 [[runners]] name = "demo" url = "http://192.168.33.20/ci" token = "0cedbafa816f5b80a496f47c4c2e1e" executor = "docker" environment = ["npm_config_cache=/cache/npm","MYSQL_ALLOW_EMPTY_PASSWORD=1"] [runners.docker] tls_verify = false image = "debian:jessie" privileged = false disable_cache = false volumes = ["/var/cache:/cache:rw","/home/vagrant/.ssh:/root/.ssh:ro"] services = ["mysql"]