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 x Docker のススメ
Search
morizyun
November 03, 2016
Programming
15
5k
GitLab CI x Docker のススメ
2016/11/1 Roppongi.rb での LTの資料です〜
morizyun
November 03, 2016
Tweet
Share
More Decks by morizyun
See All by morizyun
履歴書サービスでのLLMを使った機能の事例
morizyun
0
160
個人開発におすすめの Next.js 技術スタック
morizyun
1
1.1k
継続的個人開発のコツ
morizyun
1
51k
Digdag x Dockerでモダンなバッチ処理環境を構築
morizyun
3
25k
Mini-Heroku "Dokku"
morizyun
0
290
Overcommit & Pronto Introduction
morizyun
0
790
I Enjoyed First English LT @ RedDotRubyConf
morizyun
0
1.9k
Learning Through Blogging: Ruby Blogging Benefits
morizyun
0
880
英語で広がるRubyの世界
morizyun
4
2.2k
Other Decks in Programming
See All in Programming
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
CSC305 Lecture 26
javiergs
PRO
0
140
layerx_20241129.pdf
kyoheig3
2
290
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
180
Refactor your code - refactor yourself
xosofox
1
250
Criando Commits Incríveis no Git
marcelgsantos
2
170
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
GitHub's CSS Performance
jonrohan
1030
460k
We Have a Design System, Now What?
morganepeng
51
7.3k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Code Review Best Practice
trishagee
65
17k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
RailsConf 2023
tenderlove
29
940
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Into the Great Unknown - MozCon
thekraken
33
1.5k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Transcript
GitLab CI x Docker ΄φφϮ Japanese: @zyunnosuke English: @morizyune Roppongirb
#2
͠ڹ抑ΞҘ • morizyun(ϯϷυϲЀ);͚͜ݷڹͽϚϐϕͽ΅ၚ 㵕ͭͼ͚Δͯ • ̿ᯌ;ဴ;Ruby;Rails;̀ͼϣϺνΨ䨗͚ͼ ͚Δͯ
֟抨ͽͯ͢... • ͷΕͩ΄ϤϹωЀ΅ md2key ͽ֢ΠΔͭ ͵̶@k0kubun ͫΩ̵͘Π͢;͚ͪͬ͜ΔͯѺ
About GitLab • GitHubμϺЄЀ̶̶̶̵͞GitHubͽ͚͚ͮΙΩ • ͳ΄᭗Πͽͯ͢… • Ӯ΄Ӿ΅ᐒٖϚϐϕϼЄμ΄ϊЄφᓕቘΨ(ry • Community
EditionΟ僻ාͽςЄϝفΟΡ • ͿΩͿΩෛ䱛ᚆ᭄͢ے=> GitLab CI + Dockerڥ
About GitLab • GitHubμϺЄЀ̶̶̶̵͞GitHubͽ͚͚ͮΙΩ • ͳ΄᭗Πͽͯ͢… • Ӯ΄Ӿ΅ᐒٖϚϐϕϼЄμ΄ϊЄφᓕቘΨ(ry • Community
EditionΟ僻ාͽςЄϝفΟΡ • ͿΩͿΩෛ䱛ᚆ᭄͢ے=> GitLab CI + Dockerڥ
䱛ᚆ奧Օ: Issue Management • θЀϝЀ୵ୗ΄όφμᓕቘ (GitHub΄ProjectΞ͡ϷϷЄφ͡͵)
䱛ᚆ奧Օ: Snippet • Gist ϶αμφϘϧϐϕϑЄϸ
䱛ᚆ奧Օ: GitLab CI (氂) • GitLab ΄䱛ᚆ΄Ӟ᮱;ͭͼCI΄䱛ᚆ͘͢Ρ (GitLab 8.x͡Ο)
䱛ᚆ奧Օ: GitLab CI (氂) • GitLab ΄Ӿͽ CI / CD
͢ͽͣΡ
ͿΩίЄκϓμώϰҘ • GitLab ;΅㳨 Runner Ψ㳨αЀφϕЄϸ • Docker Container Ψ墋㶨㵕͡ͱΡ
ͿΩίЄκϓμώϰҘ • GitLab ;΅㳨 Runner Ψ㳨αЀφϕЄϸ • Docker Container Ψ墋㶨㵕͡ͱΡ
Mac ͽiOS΄ϠϸϖΘݢᚆ
ͽΘRunner΄installᶎׯͮΙҘ • GitLabςЄϝURL;TokenΨਧͯΡͶͧ # Install Docker $ curl -sSL https://get.docker.com/
| sh # Install GitLab CI runner $ curl -L https://packages.gitlab.com/install/repositories/ runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash $ sudo apt-get install gitlab-ci-multi-runner # Register the runner to GitLab $ sudo gitlab-ci-multi-runner register # => Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) # => Please enter the gitlab-ci token for this runner DockerπϫЀϖΨ ͺ͡͞ΡΞͯ͜Ρ Docker CI Runner ΨαЀφϕЄϸ GitLab ςЄϝ;Token ΨਧͯΡͶͧ https://gitlab.com/gitlab-org/gitlab-ci-multi-runner
ͩͩͽ΅ֺ;ͭͼ... (1) git push (2) ϓφϕ䋚ᤈ (4) Deploy (3) Build
Run RSpec • Travis CI;͡΄Ξ͜ .gitlab-ci.yaml ͽ戔ਧ image: ruby:2.3 services:
- "postgres:latest" - "redis:latest" variables: RAILS_ENV: test stages: - test rspec: stage: test script: - 'bundle install --path vendor/bundle’ - 'bundle exec rake db:create' - 'bundle exec rake db:migrate' - 'bundle exec rspec --format=documentation spec' πϫЀϖΨ䋚ᤈͯΡDocker αϮЄυ PostgresͿϓφϕͽֵ͜DockerΘ 厏ह䄜හ(ኮᶎ͡Ο戔ਧݢᚆ) ϓφϕ΄ಋ殼Ψ懿ᬿ
Build Docker image • Docker αϮЄυΨ֢Ρֺ(.gitlab-ci.yaml) stages: - build build_docker_image_for_test:
stage: build image: docker:1.10git script: - docker login -u="$DOCKER_USERNAME" - p="$DOCKER_PASSWORD" - docker build -t $DOCKER_IMAGE . - docker push $DOCKER_IMAGE only: master Docker ΄αϮЄυΨbuild masterϫЄυͭ͵Ο ᛔ㵕ϺЄϸίγϕ
Deploy docker image stages: - build deploy_to_production: tags: [docker] stage:
deploy environment: production script: - bash ./rollout.sh $DOCKER_IMAGE when: manual Docker ΄αϮЄυΨDeploy masterϫЄυͭ͵Ο ᛔ㵕ϺЄϸίγϕ
Tips
䶅ࢧ bundle install ΅昼͚ͥҘ • ਧ΄ path ΨκϰϐτϲͽͣΡ • bundle
install --path vendor/bundle ΄ςЀϤϸ: cache: key: “${CI_PROJECT_PATH}" untracked: true paths: - vendor/bundle
build 奾ຎ΄ϢήαϸΨכਂ • artifacts 戔ਧͽᇙਧ ϢήαϸΚϢζϸύΨ Ϡϸϖ奄՞ͧͼכਂͽͣΡ pdf: script: xelatex
mycvtex artifacts: paths: - mycvpdf
ψκϲί厏ह䄜හ΅Ҙ • ϤϺυδμϕ Master/Owner(䰱ᴴ) Ͷͧ͢ίμψφ ͽ ͣΡ Secret Variables ;
͚͜戔ਧ͘͢ΠΔͯ
docker compose΄ਧ嬝Ψֵ͚͵͚ • Docker-in-DockerͽΚΔͯ(托ͭͥ΅͚ͽͯw) image: docker:latest services: - docker:dind build:
stage: build script: - docker build -t mydockerimage . - docker run mydockerimage /scripttoruntests https://docs.gitlab.com/ce/ci/docker/using_docker_build.html
ϺЄθϸͽ Runner Ψ㵕ͭ͡͵͚ • ϺЄθϸ runner ΨύγЀϺЄϖͭͼ䋚ᤈ $ wget https://gitlab-ci-multi-runner-
downloads.s3.amazonaws.com/master/binaries/ gitlab-ci-multi-runner-darwin-amd64 $ chmod +x gitlab-ci-multi-runner-darwin-amd64 $ gitlab-ci-multi-runner-darwin-amd64 exec test https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/ install/bleeding-edge.md
.gitlab-ci.yaml΄LintϑЄϸΘ͘Ρ • 䨗͚͵ YAML Ϣήαϸ΄ဩ͢ྋ͚ͭ͡Ψ ώδϐμͯΡϑЄϸ
GitLab.com • μ϶γϖ厏हͽ׀ͫͼ͚ΡGitLab (https://about.gitlab.com/) • public, private ϷϪυϕϷΘ僻ාͽ׀ • GitLab
CI ΄ Runner Θ Digital Ocean ͢僻ාͽ ׀
Mac ͽGitLab手ͭͼΕΡ • Docker for Mac فͼ̵զӥ΄πϫЀϖΨ䋚ᤈ ͯΡͶͧ $ wget
https://raw.githubusercontent.com/sameersbn/ docker-gitlab/master/docker-compose.yml # http://qiita.com/kkanazaw/items/ 160469245fb270b1bdfd mountض΄pathΨץྋ $ docker-compose up
Happy Hacking!
݇ᘍ揾ා • GitLab CI΄奧Օ • https://about.gitlab.com/gitlab-ci/ • https://about.gitlab.com/2016/10/17/gitlab-ci-oohlala/ • https://tech.drecom.co.jp/easy-ci-development-using-gitlab-ci/
• Rails ͽ΄䌙فಋ殼 • https://www.stefanwienert.de/blog/2015/11/07/gitlab-ci-with-docker- starting-guide/ • Jenkins;΄晅͚ • http://qiita.com/namutaka/items/5114e9d9faf953bef6a4 • Heroku Ύ΄ Docker αϮЄυ΄ push ಋ殼 • https://blog.codeship.com/deploying-docker-rails-app/