Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Gitlab CI + Docker (LinuxDays 2018)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ondrej Sika
October 06, 2018
Programming
270
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Gitlab CI + Docker (LinuxDays 2018)
https://ondrej-sika.cz/blog/2018/gitlab-ci-docker-linuxdays/
Ondrej Sika
October 06, 2018
More Decks by Ondrej Sika
See All by Ondrej Sika
ZEIT, Serverless Deployments
ondrejsika
0
100
Introduction to Docker & Kubernetes @ JavaDays 2019
ondrejsika
1
330
Terraform - Infrastructure as a Code
ondrejsika
1
290
TechEd 2018, Introduction to Docker
ondrejsika
0
580
Automation using Gitlab CI and Docker, DevHeaven 2018
ondrejsika
0
220
Lightning Network aneb Bitcoin 2.0, Plzensky Barcamp, 7.4.2018
ondrejsika
0
120
Python Libraries for Bitcoin and Ethereum, PyCon SK 2018
ondrejsika
1
170
i3 tiling window manager, Install Fest 2018
ondrejsika
1
360
Docker, Zlin, 8. 2. 2018
ondrejsika
0
150
Other Decks in Programming
See All in Programming
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
120
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
610
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
350
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
840
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
360
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
170
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
140
関数型プログラミングのメリットって何だろう?
wanko_it
0
170
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
260
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
390
Claude Team Plan導入・ガイド
tk3fftk
0
180
Contextとはなにか
chiroruxx
1
390
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1033
470k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
Prompt Engineering for Job Search
mfonobong
0
370
Measuring & Analyzing Core Web Vitals
bluesmoon
9
880
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Believing is Seeing
oripsolob
1
170
Claude Code のすすめ
schroneko
67
230k
ラッコキーワード サービス紹介資料
rakko
1
3.9M
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
190
Visualization
eitanlees
152
17k
Transcript
Ondrej Sika
[email protected]
@ondrejsika Linux Days 2018, Prague, 6. 10.
2018 Gitlab CI + Docker
https://sika.link/linuxdays2018
Goals - Build application - Run tests - Deploy to
staging env.
None
What is CI?
What is CI? In software engineering, continuous integration is the
practice of merging all developer working copies to a shared mainline several times a day.
Usage of CI Automatization of - build process - testing
- deployment - dev - staging - production - code quality - Linting - Formating
Gitlab CI
Gitlab CI Architecture
Gitlab CI Runner GitLab Runner is the tool that is
used to run your jobs and send the results back to GitLab.
Gitlab CI Runner
Gitlab CI Runner Run on: - Linux - Docker -
Windows How to install & configure: - https://docs.gitlab.com/runner/install/ - https://docs.gitlab.com/runner/register/ - https://github.com/ondrejsika/gitlab-ci-runner
Install Gitlab Runner - Linux sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/b
inaries/gitlab-runner-linux-amd64 sudo chmod +x /usr/local/bin/gitlab-runner sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner sudo gitlab-runner start
Register Gitlab Runner - Linux sudo gitlab-runner register # or
gitlab-runner register --non-interactive \ --url $GITLABCI_URL \ --registration-token $GITLABCI_TOKEN
Install Gitlab Runner - Docker docker run -d \ --name
gitlab-runner \ --restart always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /builds:/builds \ gitlab/gitlab-runner:latest
Register Gitlab Runner - Docker docker exec -ti gitlab-runner gitlab-runner
register \ --non-interactive \ --url $GITLABCI_URL \ --registration-token $GITLABCI_TOKEN \ --name $(hostname) \ --executor docker \ --docker-image docker:git \ --docker-volumes '/var/run/docker.sock:/var/run/docker.sock' \ --docker-volumes '/builds:/builds'
https://github.com/ondrejsika/gitlab-ci-runner
Done, check out your Gitlab
First Job
First job git clone
[email protected]
:test/test.git cd test vim .gitlab-ci.yml git
add . git commit -m "Add CI script" git push origin master # .gitlab-ci.yml job: script: echo Hello World!
.gitlab-ci.yml
https://docs.gitlab.com/ce/ci/
Jobs - script - when - stages - only &
except - before_job & after_job - retry
Script test1_job: script: echo 'Run test1 ...' test2_job: script: -
echo Run 'test2.1 ...' - echo Run 'test2.2 ...' - echo Run 'test2.3 ...'
Stages stages: - build - test - deploy build_job: stage:
build script: echo 'Building ...' test1_job: stage: test script: echo Run test1 ...' test2_job: stage: test script: echo Run test2 ...'
When cleanup_build_job: script: echo Cleanup build when failed ... when:
on_failure test_job: script: echo Run test ... deploy_job: script: echo Deploy ... when: manual cleanup_job: script: echo Full cleanup ... when: always
Only & Except job: # use regexp only: - /^issue-.*$/
# use special keyword except: - branches
Variables - Secret variables are defined in Gitlab - Some
variables set CI runtime - Public variables are defined in .gitlab-ci.yml
Variables CI CI_PROJECT_NAME, CI_PROJECT_PATH_SLUG CI_COMMIT_REF_NAME, CI_COMMIT_REF_SLUG CI_COMMIT_SHA, CI_COMMIT_TAG CI_PIPELINE_ID, CI_JOB_ID
CI_REGISTRY, CI_REGISTRY_USER, CI_REGISTRY_PASSWORD ... https://docs.gitlab.com/ce/ci/variables/README.html
Variables variables: IMAGE_TAG: myapp:$CI_PIPELINE_ID job: script: docker build -t $IMAGE_TAG
.
Docker - Fully supported - Easiest way how to create
build environment - Easiest way how to run and distribute your software
Docker Environment image: ondrejsika/ci job: image: ondrejsika/ci-go script: go build
server.go
Docker job: script: - docker build -t $IMAGE . -
docker push $IMAGE
Environments Environment is used to define that a job deploys
to a specific environment. If environment is specified and no environment under that name exists, a new one will be created automatically.
Environment deploy: script: echo 'Deploy!' environment: name: $CI_COMMIT_REF_SLUG url: https://$CI_COMMIT_REF_SLUG.example.com
Deployments - Automatic - Manual
Auto vs Manual Deployments auto_deploy_job: script: echo Auto Deploy! environment:
name: deployment-$CI_PIPELINE_ID manual_deploy_job: when: manual script: echo Manual Deploy! environment: name: deployment-$CI_PIPELINE_ID
Stop Deployment deploy_job: stage: deploy script: echo Deploy! environment: name:
deployment-$CI_PIPELINE_ID on_stop: stop_deploy_job stop_deploy_job: stage: deploy script: echo Stop! when: manual environment: name: deployment-$CI_PIPELINE_ID action: stop
Try it!
https://github.com/ondrejsika/linuxdays2018
https://gitlab-demo.xsika.cz/demo/linuxdays2018
Resources - https://about.gitlab.com/features/gitlab-ci-cd/ - https://docs.gitlab.com/ce/ci/ - https://docs.gitlab.com/ce/ci/yaml/ - https://docs.gitlab.com/ce/ci/quick_start/ -
https://ondrej-sika.cz/blog/2018/gitlab-ci-docker-linuxdays/ - https://github.com/ondrejsika/ondrejsika-ci-docker - https://github.com/ondrejsika/traefik-ssl - https://github.com/ondrejsika/gitlab-ci-runner
Thank you & Questions Ondrej Sika email:
[email protected]
web: https://ondrej-sika.cz
twitter: @ondrejsika linkedin: /in/ondrejsika/ https://sika.link/linuxdays2018