Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
A smooth migration to Docker focusing on build ...
Search
PaulRbr
October 06, 2017
Programming
35
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
A smooth migration to Docker focusing on build pipelines
PaulRbr
October 06, 2017
More Decks by PaulRbr
See All by PaulRbr
How can automation help with development practices
paulrbr
0
18
Production upgrade of PostgreSQL 9.1 to 9.5
paulrbr
0
38
Other Decks in Programming
See All in Programming
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
2.3k
Family mrubyの進捗
kishima
1
130
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
220
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
250
速習iPhone Duo対応
yuukiw00w
1
690
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
220
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
150
setup-vp GitLab対応の裏側
naokihaba
0
120
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
630
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
280
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
350
What We Talk About When We Talk About XP
m_seki
2
660
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
My Coaching Mixtape
mlcsv
0
320
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
700
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
A designer walks into a library…
pauljervisheath
211
25k
Test your architecture with Archunit
thirion
2
2.4k
4 Signs Your Business is Dying
shpigford
187
23k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
280
Designing for Timeless Needs
cassininazir
1
480
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Speed Design
sergeychernyshev
33
2.1k
Transcript
Paul Bonaud @paulrb_r Maxime Visonneau @mvisonneau A SMOOTH MIGRATION TO
DOCKER FOCUSING ON BUILD PIPELINES
↓ ↓
Paul Bonaud ⌨ + ⚙ + ▶ Infra & Ops
Engineer ⏸ So ware Developer Maxime Visonneau ⌨ + + Infrastructure Engineer
Meet Maurice
None
Meet Maurice aka build2
None
Manually administrated
None
Building all projects Android, JS (Ember), C++, Ruby
None
Deploying everything Nginx, apps, infrastructure
None
Single architecture (Debian 7)
None
New era
None
Docker
Open Source ❤
Isolated
Immutable
Stateless
Version controlled Dockerfile
Dockerfile FROM ruby:2.4-jessie RUN apt-get update RUN apt-get -y install
libpq-dev ghostscript WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
Dockerfile FROM ruby:2.4-jessie RUN apt-get update RUN apt-get -y install
libpq-dev ghostscript WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
Dockerfile FROM ruby:2.4-jessie RUN apt-get update && \ apt-get -y
install libpq-dev ghostscript && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
Dockerfile FROM ruby:2.4-jessie RUN apt-get update && \ apt-get -y
install libpq-dev ghostscript && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
Dockerfile FROM ruby:2.4-jessie RUN apt-get update && \ apt-get -y
install libpq-dev ghostscript && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
Dockerfile FROM ruby:2.4-jessie RUN apt-get update && \ apt-get -y
install libpq-dev ghostscript && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
GitLab
Open Source ❤
None
None
Integrated Docker registry! registry.gitlab.com
Gitlab-CI
Open Source ❤
Declarative
Integrated
Version controlled .gitlab-ci.yml
.gitlab-ci.yml stages: - build - test - package - deploy
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} LATEST_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest build:docker: stage: build tags:
[ privileged ] image: "docker:latest" before_script: - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} script: - docker pull ${LATEST_IMAGE} || true - docker build --cache-from ${LATEST_IMAGE} -t ${IMAGE} -t ${LATEST_IMAGE} . - docker push ${IMAGE} - docker push ${LATEST_IMAGE}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} LATEST_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest build:docker: stage: build tags:
[ privileged ] image: "docker:latest" before_script: - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} script: - docker pull ${LATEST_IMAGE} || true - docker build --cache-from ${LATEST_IMAGE} -t ${IMAGE} -t ${LATEST_IMAGE} . - docker push ${IMAGE} - docker push ${LATEST_IMAGE}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} LATEST_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest build:docker: stage: build tags:
[ privileged ] image: "docker:latest" before_script: - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} script: - docker pull ${LATEST_IMAGE} || true - docker build --cache-from ${LATEST_IMAGE} -t ${IMAGE} -t ${LATEST_IMAGE} . - docker push ${IMAGE} - docker push ${LATEST_IMAGE}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} LATEST_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_PATH}:latest build:docker: stage: build tags:
[ privileged ] image: "docker:latest" before_script: - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} script: - docker pull ${LATEST_IMAGE} || true - docker build --cache-from ${LATEST_IMAGE} -t ${IMAGE} -t ${LATEST_IMAGE} . - docker push ${IMAGE} - docker push ${LATEST_IMAGE}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} # (...) image: ${IMAGE}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} # (...) image: ${IMAGE} test: stage:
test script: - make test
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} # (...) image: ${IMAGE} test: stage:
test script: - make test package: stage: package script: - make package > release.tar.gz artifacts: paths: [ release.tar.gz ]
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} # (...) deploy:integration: stage: deploy image:
${CI_REGISTRY}/infra/ansible:latest variables: ENV: integration script: - make deploy file=release.tar.gz env=${ENV}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} # (...) deploy:integration: &deploy stage: deploy
image: ${CI_REGISTRY}/infra/ansible:latest variables: ENV: integration script: - make deploy file=release.tar.gz env=${ENV} deploy:production: <<: *deploy when: manual variables: ENV: production
What about easy OS testing and upgrades?!
Dockerfile FROM ruby:2.4-jessie RUN apt-get update RUN apt-get -y install
libpq-dev ghostscript WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
Dockerfile FROM ruby:2.4-stretch RUN apt-get update RUN apt-get -y install
libpq-dev ghostscript WORKDIR /opt/app COPY Gemfile Gemfile.lock /opt/app RUN bundle install VOLUME /opt/app CMD [ "make", "run" ]
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} # (...) image: ${IMAGE}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${OS}_${CI_COMMIT_SHA} # (...) image: ${IMAGE}
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${OS}_${CI_COMMIT_SHA} # (...) image: ${IMAGE} test:jessie: stage:
test variables: OS: jessie script: - make test
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${OS}_${CI_COMMIT_SHA} # (...) image: ${IMAGE} test:jessie: &test
stage: test variables: OS: jessie script: - make test test:stretch: <<: *test variables: OS: stretch
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${OS}_${CI_COMMIT_SHA} # (...) image: ${IMAGE} package:jessie: &package
stage: package variables: OS: jessie script: - make package > release-${OS}.tar.gz artifacts: paths: [ release-${OS}.tar.gz ] package:stretch: <<: *package variables: OS: stretch
.gitlab-ci.yml variables: IMAGE: ${CI_REGISTRY_IMAGE}:${OS}_${CI_COMMIT_SHA} # (...) deploy:integration: &deploy stage: deploy
image: ${CI_REGISTRY}/infra/ansible:latest variables: OS: stretch ENV: integration script: - make deploy file=release-${OS}.tar.gz env=${ENV} deploy:production: <<: *deploy when: manual variables: OS: jessie ENV: production
None
Runners
Di erent Executors / Multiple OSes Shell Docker VirtualBox Parallels
SSH Kubernetes Linux Windows Mac OS X FreeBSD
Di erent Executors / Multiple OSes Shell Docker VirtualBox Parallels
SSH Kubernetes Linux Windows Mac OS X FreeBSD
Portable
Light system dependencies
Easily configurable and maintainable
--- classes: - docker - gitlab::ci gitlab::ci::runners: "%{::fqdn}_docker": executor: docker
docker-image: docker:latest
--- classes: - docker - gitlab::ci gitlab::ci::runners: "%{::fqdn}_docker": executor: docker
docker-image: docker:latest docker-volumes: "/var/run/docker.sock:/var/run/docker.sock" docker-privileged: true
AWS
Terraform
Open Source ❤
terraform.tf resource "aws_instance" "gitlab_runner" { count = 10 ami =
"ami-6b2cd712" instance_type = "m4.large" [..] }
None
None
MISSINGDEP Who had any clue this system library was required?
MISSINGDEP Update Dockerfiles with missing dependencies
ENOSPC No space le on device
ENOSPC Increase space / Automate cleanup of old containers and
images
UNAUTH_DEPLOY Where are my SSH keys for Ansible?
UNAUTH_DEPLOY Enhance security by creating individual keys per project/env
SHM_OOM Less than 64MB of free space in temporary directory
for shared memory files
SHM_OOM Configure max SHM size
IOWAIT On heavy load tests
IOWAIT Bigger disks Provisioned IOPS Leverage tmpfs
None
None
None
AWS
Docker
Terraform
terraform.tf resource "aws_autoscaling_group" "gitlab_runner" { desired_capacity = 10 min_size =
4 max_size = 24 launch_configuration = "${aws_launch_configuration.runner.name}" [..] }
We can do better and easier!
Ourselves with an interesting challenge
So ware engineers with a reliable CI implementation
Finance by making some savings
docker-machine integrated out-of-the-box with gitlab-runner scheduling jobs on spot instances
gitlab::ci::runners: 'aws_spot_docker_machine': executor: docker+machine limit: 24 machine-IdleCount: 4 machine-IdleTime: 600
machine-OffPeakPeriods: - "* * 0-8,18-23 * * mon-fri *" - "* * * * * sat,sun *" machine-OffPeakIdleCount: 0 machine-OffPeakIdleTime: 600 machine-MaxBuilds: 30 machine-MachineDriver: amazonec2 machine-MachineOptions: - amazonec2-instance-type=m4.large - amazonec2-request-spot-instance=true - amazonec2-spot-price=0.10 [..]
gitlab::ci::runners: 'aws_spot_docker_machine': executor: docker+machine limit: 24 machine-IdleCount: 4 machine-IdleTime: 600
machine-OffPeakPeriods: - "* * 0-8,18-23 * * mon-fri *" - "* * * * * sat,sun *" machine-OffPeakIdleCount: 0 machine-OffPeakIdleTime: 600 machine-MaxBuilds: 30 machine-MachineDriver: amazonec2 machine-MachineOptions: - amazonec2-instance-type=m4.large - amazonec2-request-spot-instance=true - amazonec2-spot-price=0.10 [..]
gitlab::ci::runners: 'aws_spot_docker_machine': executor: docker+machine limit: 24 machine-IdleCount: 4 machine-IdleTime: 600
machine-OffPeakPeriods: - "* * 0-8,18-23 * * mon-fri *" - "* * * * * sat,sun *" machine-OffPeakIdleCount: 0 machine-OffPeakIdleTime: 600 machine-MaxBuilds: 30 machine-MachineDriver: amazonec2 machine-MachineOptions: - amazonec2-instance-type=m4.large - amazonec2-request-spot-instance=true - amazonec2-spot-price=0.10 [..]
gitlab::ci::runners: 'aws_spot_docker_machine': executor: docker+machine limit: 24 machine-IdleCount: 4 machine-IdleTime: 600
machine-OffPeakPeriods: - "* * 0-8,18-23 * * mon-fri *" - "* * * * * sat,sun *" machine-OffPeakIdleCount: 0 machine-OffPeakIdleTime: 600 machine-MaxBuilds: 30 machine-MachineDriver: amazonec2 machine-MachineOptions: - amazonec2-instance-type=m4.large - amazonec2-request-spot-instance=true - amazonec2-spot-price=0.10 [..]
gitlab::ci::runners: 'aws_spot_docker_machine': executor: docker+machine limit: 24 machine-IdleCount: 4 machine-IdleTime: 600
machine-OffPeakPeriods: - "* * 0-8,18-23 * * mon-fri *" - "* * * * * sat,sun *" machine-OffPeakIdleCount: 0 machine-OffPeakIdleTime: 600 machine-MaxBuilds: 30 machine-MachineDriver: amazonec2 machine-MachineOptions: - amazonec2-instance-type=m4.large - amazonec2-request-spot-instance=true - amazonec2-spot-price=0.10 [..]
gitlab::ci::runners: 'aws_spot_docker_machine': executor: docker+machine limit: 24 machine-IdleCount: 4 machine-IdleTime: 600
machine-OffPeakPeriods: - "* * 0-8,18-23 * * mon-fri *" - "* * * * * sat,sun *" machine-OffPeakIdleCount: 0 machine-OffPeakIdleTime: 600 machine-MaxBuilds: 30 machine-MachineDriver: amazonec2 machine-MachineOptions: - amazonec2-instance-type=m4.large - amazonec2-request-spot-instance=true - amazonec2-spot-price=0.10 [..]
gitlab::ci::runners: 'aws_spot_docker_machine': executor: docker+machine limit: 24 machine-IdleCount: 4 machine-IdleTime: 600
machine-OffPeakPeriods: - "* * 0-8,18-23 * * mon-fri *" - "* * * * * sat,sun *" machine-OffPeakIdleCount: 0 machine-OffPeakIdleTime: 600 machine-MaxBuilds: 30 machine-MachineDriver: amazonec2 machine-MachineOptions: - amazonec2-instance-type=m4.large - amazonec2-request-spot-instance=true - amazonec2-spot-price=0.10 [..]
None
None
A small drawback..
Scheduling
Kubernetes
--- apiVersion: v1 kind: ConfigMap metadata: name: gitlab-runner namespace: gitlab-ci
data: config.toml: | [[runners]] name = "k8s_runner" url = "https://gitlab.example.com/" executor = "kubernetes" [runners.kubernetes] cpu_limit = "1" memory_limit = "256Mi" [..]
~$ kubectl -n gitlab-ci get po NAME READY STATUS RESTARTS
AGE runner-315e4d80-0qj79g 2/2 Running 0 3m runner-315e4d80-9kdkee 2/2 Running 0 2m runner-315e4d80-kdfdfe 2/2 Running 0 1m runner-315e4d80-ldorpk 2/2 Running 0 1m runner-315e4d80-pleofi 2/2 Running 0 20s
Definitely promising
Still a work in progress for us
None
QUESTIONS?
REFERENCES · Dockerfile documentation · .gitlab-ci.yml documentation · Slides https://docs.docker.com/engine/reference/builder/
https://gitlab.com/help/ci/yaml/README.md http://polr.fr/tiaddocker