Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Railsエンジニア向けDocker入門 / Docker description for R...
Search
Takumi Shotoku
December 02, 2021
Technology
0
730
Railsエンジニア向けDocker入門 / Docker description for Rails engineers
Omotesando.rb #69
https://omotesandorb.connpass.com/event/231730/
Takumi Shotoku
December 02, 2021
Tweet
Share
More Decks by Takumi Shotoku
See All by Takumi Shotoku
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
180
"型"のあるRailsアプリケーション開発 / Typed Rails application development
sinsoku
9
2.4k
Let's get started with Ruby && Rails Tips
sinsoku
0
360
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
330
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1.2k
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1.4k
💎のつくりかた 2023 / How to make gems 2023
sinsoku
2
340
Make tests run faster
sinsoku
2
650
YARD with RBS Syntax
sinsoku
1
490
Other Decks in Technology
See All in Technology
振る舞い駆動開発(BDD)における、テスト自動化の前に大切にしていること #stac2024 / BDD formulation
nihonbuson
2
790
店舗向けSaaSにおける 顧客要望活用の実践アプローチ(20241205_pmconf)
yujirooo
0
3k
ゆるSRE勉強会 #8 組織的にSREが始まる中で意識したこと
abnoumaru
2
1.1k
241130紅白ぺぱ合戦LT「編集の技術」
toya524287
5
630
2024/12/05 AITuber本著者によるAIキャラクター入門 - AITuberの基礎からソフトウェア設計、失敗談まで
sr2mg4
2
550
GitHub Actions의 다양한 기능 활용하기 - GitHub Universe '24 Recap
outsider
0
450
開志専門職大学特別講義 2024 オープニング
1ftseabass
PRO
0
230
EthernetベースのGPUクラスタ導入による学びと展望
lycorptech_jp
PRO
0
570
12/4(水)のBedrockアプデ速報(re:Invent 2024 Daily re:Cap #3 with AWS Heroes)
minorun365
PRO
2
400
宇宙最速のランチRecap LT会(開発者ツール&運用監視編)
nnydtmg
0
150
How is Cilium Tested?
yutarohayakawa
5
290
品質管理チームのEMとして大事にしていること / QA EM
nihonbuson
0
780
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
Agile that works and the tools we love
rasmusluckow
328
21k
What's in a price? How to price your products and services
michaelherold
243
12k
Making the Leap to Tech Lead
cromwellryan
133
9k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
480
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Designing Experiences People Love
moore
138
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
1
89
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