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
Rails on Docker
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Daiki Hirakata
May 10, 2018
Technology
580
2
Share
Rails on Docker
2018/5/10の表参道.rbで発表した資料です。
#omotesandorb
Daiki Hirakata
May 10, 2018
More Decks by Daiki Hirakata
See All by Daiki Hirakata
Firestoreコスト圧縮の旅
bigplants
0
51
Road to k8s
bigplants
0
280
Next Level Git
bigplants
0
660
AWSを使っているならOpsWorksでDevOpsしよう!
bigplants
1
1.8k
Other Decks in Technology
See All in Technology
AIが変えた"品質の守り方"
kkakizaki
13
5.4k
Javaで学ぶSOLID原則
negima
1
240
はじめてのDatadog
kairim0
0
240
string地獄を脱出する
sansantech
PRO
1
110
AI時代から振り返るTerraform drift運用の歴史 / AI Age Reflections on the History of Terraform Drift Operations
aeonpeople
0
600
20260528_生成AIを専属DSに_Howの次にすべきことを考える
doradora09
PRO
0
260
ビジュアルプログラミングIoTLT vol.23
1ftseabass
PRO
0
160
AI Adaptable なテストを整える工夫 / Ways to Make Your Tests AI-Adaptable
bitkey
PRO
2
180
速さだけじゃない! VoidZero ツールが移行先に選ばれる理由
mizdra
PRO
6
690
テストコードのないプロジェクトにテストを根付かせる
tttol
0
230
OpenClawとHermesAgentでAI新入社員を作った話
takanoriyanada
0
150
Agentic AI時代における メルカリのAIガバナンスとガードレール実装
naoichihara
16
17k
Featured
See All Featured
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
230
Faster Mobile Websites
deanohume
310
31k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
190
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
210
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
290
エンジニアに許された特別な時間の終わり
watany
107
240k
Music & Morning Musume
bryan
47
7.2k
Facilitating Awesome Meetings
lara
57
6.9k
Prompt Engineering for Job Search
mfonobong
0
320
How to Ace a Technical Interview
jacobian
281
24k
Transcript
Rails on Docker @bigplants May 10th 2018 @Omotesando.rb
Who am I ? • Daiki Hirakata (36) • Software
Engineer • Main Programing Languages: PHP, Ruby • Primary interests: DevOps, Docker, Kubernetes, Microservice Architecture, GCP @bigplants
࠷ۙϥϯχϯά͡Ί·ͨ͠
ͪΐͬͱ͚ͩએ
ઈࢍ։ൃऀืूதʂ • ϓϩμΫτ໊: ALL-IN • اۀ׆ಈͰඞཁͳશͯͷ πʔϧ͕ೖ͍ͬͯΔ • Rails, Angular,
AWS • גࣜձࣾϏδωεόϯΫ άϧʔϓ
ݱࡏɺεςʔδϯάڥΛ ઈࢍKubernetesҠߦதͰ͢ɻ
ϩʔυϚοϓ • ։ൃ༻ίϯςφ४උ • ެ։༻ίϯςφ४උ • GKEʹσϓϩΠ <- ΠϚίί •
CI/CDύΠϓϥΠϯͷඋ ͍ͭͰ୭Ͱ͓खܰʹk8sΫϥελʹڥߏங&σ ϓϩΠͰ͖ΔΑ͏ʹ͢Δ
ࢦͤʂ ແݶεςʔδϯάͷ࣮ݱʂ
ࠓެ։ڥ༻ͷ Rails on Docker ͳΛ͠·͢ɻ × ΄΅dockerͷͰ͢ɻɻ
Rails appΛ docker build͢Δͱ͖
݁ߏΔ͜ͱ͋Δ • bundle install • npm install • rake bower:install
• rake bower:resolve • rake assets:precompile • And more tasks…
ނʹɺdocker buildʹ ͔͔࣌ؒΔ Լख͢Δͱover 10min
ߋʹΠϝʔδαΠζͷංେԽ Լख͢Δͱover 1.5GB
docker build1secͰૣ͍ ΄͏͕͍͍ git pushͷʹCIʹdocker build͍ͤͨ͞
docker image1MBͰܰ ͍΄͏͕͍͍ Google Container Registoryͷ ΞοϓϩʔυɺGKEͷσϓϩΠʹӨڹ͢Δ
docker build docker push git push kubectl apply get image
docker build docker push git push kubectl apply get image
Ϗϧυʹ͔͔࣌ؒΔͱ
docker build docker push git push kubectl apply get image
ΠϝʔδͷαΠζ͕σΧΠͱ
Ϗϧυͷ࣌ؒΛॖ͢Δʹʁ
ΩϟογϡΛ͏·͔ͭ͘͏
None
ΠϝʔδͷαΠζΛ͑Δʹ
·ͣඞཁͳͷΛશ෦ೖΕΔ
ཁΒͳ͍ͷΛআ ಉ͡Dockerfile
͏Ұίϐʔ ಉ͡Dockerfile
͜ΕͰΠϝʔδͷαΠζ͕ 1.5GB -> 500MB͘Β͍ʹʂ ※͋͘·ͰචऀͷڥͰͷͰ͢
Tips
docker buildͰڥมΛॻ ͖͑Δʹ
docker buildͰENVΛͤͳ ͍
--build-arg͕͑ͦ͏
ARGͰENVΛॻ͖͑Δ • docker build --build-arg RAILS_ENV=production --build-arg HOGE=fuga
ARGͷҐஔॏཁ
ARGͷҐஔॏཁ
RUNͰڥมΛૢ࡞͢Δ ͖Ͱͳ͍ • ͨͩͷshellͩͱ͍͏ࣄΛཧղ͢Δ
ϨΠϠ͕͔ΕΔͱͦΕͧΕ༰ྔΛ৯͏ɻͳΔ͘RUN·ͱΊΔ ͋ͱ͔Βআͯ͠Πϝʔδα ΠζมΘΒͳ͍
͘͠ɺ͖ͬ͞ग़͖ͯͨ Multi-stage buildͷςΫχο ΫͰ
docker history <image>ͰͲ ͜ͰαΠζ͕ΒΜͰΔ͔֬ೝ
σόοάͷͨΊʹ͍Βͳ͍ͷΛআ͢Δ લͷঢ়ଶͰ֬ೝͰ͖ΔΑ͏ʹεςʔδΛΘ ͚Δ • docker build --target <stage name> -t
<tag>
ࠓͷ·ͱΊ • ϏϧυߴԽͷҝʹΩϟογϡΛ͏·͓͘ ͏ • ΠϝʔδαΠζͷѹॖͷͨΊʹMulti-stage build͠Α͏