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
Daiki Hirakata
May 10, 2018
Technology
2
560
Rails on Docker
2018/5/10の表参道.rbで発表した資料です。
#omotesandorb
Daiki Hirakata
May 10, 2018
Tweet
Share
More Decks by Daiki Hirakata
See All by Daiki Hirakata
Firestoreコスト圧縮の旅
bigplants
0
40
Road to k8s
bigplants
0
270
Next Level Git
bigplants
0
630
AWSを使っているならOpsWorksでDevOpsしよう!
bigplants
1
1.7k
Other Decks in Technology
See All in Technology
対話型音声AIアプリケーションの信頼性向上の取り組み
ivry_presentationmaterials
2
690
ビジネス職が分析も担う事業部制組織でのデータ活用の仕組みづくり / Enabling Data Analytics in Business-Led Divisional Organizations
zaimy
1
310
推し書籍📚 / Books and a QA Engineer
ak1210
0
120
サイバーエージェントグループのSRE10年の歩みとAI時代の生存戦略
shotatsuge
4
830
モニタリング統一への道のり - 分散モニタリングツール統合のためのオブザーバビリティプロジェクト
niftycorp
PRO
1
360
オフィスビルを監視しよう:フィジカル×デジタルにまたがるSLI/SLO設計と運用の難しさ / Monitoring Office Buildings: The Challenge of Physical-Digital SLI/SLO Design & Operation
bitkey
1
350
IPA&AWSダブル全冠が明かす、人生を変えた勉強法のすべて
iwamot
PRO
2
220
20250707-AI活用の個人差を埋めるチームづくり
shnjtk
6
4.1k
事例で学ぶ!B2B SaaSにおけるSREの実践例/SRE for B2B SaaS: A Real-World Case Study
bitkey
1
340
AIエージェントが書くのなら直接CloudFormationを書かせればいいじゃないですか何故AWS CDKを使う必要があるのさ
watany
18
7k
SRE不在の開発チームが障害対応と 向き合った100日間 / 100 days dealing with issues without SREs
shin1988
2
1.5k
VGGT: Visual Geometry Grounded Transformer
peisuke
1
620
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
KATA
mclloyd
30
14k
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
The Invisible Side of Design
smashingmag
301
51k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Side Projects
sachag
455
42k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
Typedesign – Prime Four
hannesfritz
42
2.7k
4 Signs Your Business is Dying
shpigford
184
22k
Site-Speed That Sticks
csswizardry
10
700
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
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͠Α͏