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
KubeCon + CloudNativeCon Japan 2025 に行ってきた! & containerd の新機能紹介
honahuku
0
120
How Community Opened Global Doors
hiroramos4
PRO
1
130
2025-06-26_Lightning_Talk_for_Lightning_Talks
_hashimo2
2
110
ビズリーチが挑む メトリクスを活用した技術的負債の解消 / dev-productivity-con2025
visional_engineering_and_design
0
330
FOSS4G 2025 KANSAI QGISで点群データをいろいろしてみた
kou_kita
0
280
AWS テクニカルサポートとエンドカスタマーの中間地点から見えるより良いサポートの活用方法
kazzpapa3
2
610
あなたの声を届けよう! 女性エンジニア登壇の意義とアウトプット実践ガイド #wttjp / Call for Your Voice
kondoyuko
4
510
Delegating the chores of authenticating users to Keycloak
ahus1
0
130
「良さそう」と「とても良い」の間には 「良さそうだがホンマか」がたくさんある / 2025.07.01 LLM品質Night
smiyawaki0820
1
440
fukabori.fm 出張版: 売上高617億円と高稼働率を陰で支えた社内ツール開発のあれこれ話 / 20250704 Yoshimasa Iwase & Tomoo Morikawa
shift_evolve
PRO
1
340
Tokyo_reInforce_2025_recap_iam_access_analyzer
hiashisan
0
140
AWS Summit Japan 2025 Community Stage - App workflow automation by AWS Step Functions
matsuihidetoshi
1
310
Featured
See All Featured
KATA
mclloyd
30
14k
Side Projects
sachag
455
42k
Why Our Code Smells
bkeepers
PRO
337
57k
Navigating Team Friction
lara
187
15k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.8k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
4 Signs Your Business is Dying
shpigford
184
22k
Site-Speed That Sticks
csswizardry
10
670
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͠Α͏