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
39
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
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
Jetpack Compose Mechanisms
skydoves
3
820
golang-bob.pdf
iwatsukayura
0
130
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
110
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
3.8k
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
33k
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
contenteditable と日本語入力に向き合う
colorful12
0
200
JIS keyboard support in Omarchy
lef237
0
130
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Automating Front-end Workflow
addyosmani
1369
210k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
4 Signs Your Business is Dying
shpigford
187
23k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
310
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
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