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エンジニア向けDocker入門 / Docker description for R...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Takumi Shotoku
December 02, 2021
Technology
880
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Railsエンジニア向けDocker入門 / Docker description for Rails engineers
Omotesando.rb #69
https://omotesandorb.connpass.com/event/231730/
Takumi Shotoku
December 02, 2021
More Decks by Takumi Shotoku
See All by Takumi Shotoku
TypeProf 開発レポート 2026-05 / TypeProf Dev Report 2026-05
sinsoku
1
140
Automatically generating types by running tests
sinsoku
4
19k
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
8
2.9k
テストを書かないためのテスト/ Tests for not writing tests
sinsoku
1
310
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
360
"型"のあるRailsアプリケーション開発 / Typed Rails application development
sinsoku
11
3.1k
Let's get started with Ruby && Rails Tips
sinsoku
0
510
LTの敷居を下げる / Lower the threshold for LT
sinsoku
2
450
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1.6k
Other Decks in Technology
See All in Technology
Head First モブプログラミング / Head First Mobprogramming
takaking22
10
12k
Goでデータパイプラインを作ろう
sansantech
PRO
1
500
その“隠したつもり”が命取り ── 自前と平文をやめて「正解」に委ねる
kuroneko13
0
130
ブラウザ研修 2026
recruitengineers
PRO
6
1.1k
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
5
1.9k
ガバメント AI 源内を地方自治体は活用できるのか可能性と課題、期待について
takeda_h
2
440
AIのためのEthernet技術動向 (SerDes)
markunet
1
200
Kiro Crew入門 - 常駐エージェントの仕組みと使いどころ / Intro to Kiro Crew
k_adachi_01
1
370
案件に一番詳しいAIを Amazon Bedrock AgentCore で作る ― 知見が知見を生むチームへ / Compounding Knowledge with AgentCore
yusukeshimizu
1
130
事業価値と Engineering 2026年度版
recruitengineers
PRO
51
25k
SmartHR Engineering Team Deck
smarthr
1
2.4k
Go 1.27 の標準パッケージに uuid が入った!のでいろいろ喋る / go_127_std_go_uuid
convto
1
230
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
440
Optimising Largest Contentful Paint
csswizardry
37
3.9k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
540
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Building an army of robots
kneath
306
46k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
25k
Leo the Paperboy
mayatellez
8
2.1k
sira's awesome portfolio website redesign presentation
elsirapls
0
320
How to build a perfect <img>
jonoalderson
1
5.9k
Transcript
RailsΤϯδχΞ͚Dockerೖ Omotesando.rb #68 2021/12/02 1
ࣗݾհ • ໊લ: ਖ਼ಙ (aka: ਆ) • ձࣾ: ϝυϐΞגࣜձࣾ •
ॴଐ: CTOࣨSRE • GitHub: @sinsoku (ը૾ӈ্) • Twitter: @sinsoku_listy (ը૾ӈԼ) 2
࠷ߴͷϒϩάΞϓϦΛ࡞Δ (3min) $ rails new omotesando_blog $ cd omotesando_blog $
bin/rails g scaffold blog title body:text $ bin/rails db:prepare $ bin/rails s 3
ϒϩά͕ߘͰ͖Δʂ͍͢͝ʂ 4
ଞPCͰ؆୯ʹಈ͘Α͏ʹ͍ͨ͠ 5
Dockerͷ༻్ ͦͷ1 ΞϓϦ ͷίϯςφԽ 6
ΞϓϦͷίϯςφԽ omotesando_blog ͱ͍͏όΠφϦΛ࡞Δͷʹ͍ۙɻ $ docker run omotesando_blog bin/rails --version $
docker run omotesando_blog bin/rails stats omotesando_blog ͷDockerΠϝʔδʹιʔείʔυɺRubyɺ gemɺnpmؚ͕·Ε͍ͯΔͷͰɺར༻ऀDocker͚ͩ༻ҙ͢Ε ྑ͍ɻ 7
Dockerfile ͷྫ1 FROM ruby:3.0.3 WORKDIR /workspace # Install Node.js, Yarn
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - RUN apt-get update && apt-get install -y nodejs RUN npm install --global yarn # ιʔείʔυΛՃ͢Δ COPY . /workspace # gemnpmΛՃ͢Δ RUN bin/setup 8
Ϗϧυͯ͠ࢼ͢ $ docker build -t omotesando_blog . $ docker run
-p 3000:3000 \ omotesando_blog bin/rails s -b 0.0.0.0 9
Dockerศར 10
։ൃڥ ! ʹ͢Εศར...ʁ 11
Dockerfile ͷྫ1ʢ࠶ܝʣ FROM ruby:3.0.3 WORKDIR /workspace # Install Node.js, Yarn
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - RUN apt-get update && apt-get install -y nodejs RUN npm install --global yarn # ιʔείʔυΛՃ͢Δ COPY . /workspace # gemnpmΛՃ͢Δ RUN bin/setup 12
ίʔυมߋ͢ΔʹϏϧυ͕ඞཁ 13
Dockerͷ༻్ ͦͷ2 ڥ ͷίϯςφԽ 14
Dockerfile ͷྫ2 FROM ruby:3.0.3 WORKDIR /workspace # Install Node.js RUN
curl -fsSL https://deb.nodesource.com/setup_14.x | bash - RUN apt-get update && apt-get install -y nodejs # Install Yarn RUN curl -o- -L https://yarnpkg.com/install.sh | bash # Set env to install gems into /workspace/vendor/bundle ENV BUNDLE_PATH vendor/bundle 15
Ϗϧυͯ͠ࢼ͢ $ docker build -t omotesando_blog:v2 . $ docker run
-v `pwd`:/workspace \ omotesando_blog:v2 bin/setup $ docker run -v `pwd`:/workspace -p 3000:3000 \ omotesando_blog:v2 bin/rails s -b 0.0.0.0 omotesando_blog:v2 ʹRubyɺNode.jsɺYarnؚ·Ε͍ͯΔɻ ։ൃதʹมߋ͢Δ͜ͱͷ͋ΔίʔυɺgemɺnpmΠϝʔδʹؚ Ίͳ͍ɻ 16
·ͱΊ Dockerͷ༻్2ͭ͋Δɻ 1. ΞϓϦͷίϯςφԽ 2. ڥͷίϯςφԽ ༻్ʹΑͬͯDockerfileͰؾΛ͚ͭΔ͕มΘΔͷͰҙ͕͍Δɻ 17