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
Takumi Shotoku
December 02, 2021
Technology
0
690
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
Let's get started with Ruby && Rails Tips
sinsoku
0
330
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
300
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1.2k
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1.3k
💎のつくりかた 2023 / How to make gems 2023
sinsoku
2
300
Make tests run faster
sinsoku
2
620
YARD with RBS Syntax
sinsoku
1
440
Get started with OSS contributions
sinsoku
2
1.1k
Advice for Ruby beginners
sinsoku
2
470
Other Decks in Technology
See All in Technology
標準最高!標準はださくないぞ! at fukuoka.ts #1
yoiwamoto
0
150
#Zenoh 完全に理解した 〜組込み純情篇〜
takasehideki
1
460
Oracle Database 23ai 新機能 #3 Oracle Globally Distributed Database(GDD)
oracle4engineer
PRO
1
160
MySQLユーザ会なにやってるの?とおさそいと / たいへんなのw
sakaik
1
100
「名前解決」から振り返るAmazon VPC
yuki_ink
0
320
突撃! 隣のAmazon Bedrockユーザー 〜YouはどうしてAWSで?〜
minorun365
PRO
2
170
疎通2024
sadnessojisan
5
810
LLM を現場で評価する
asei
4
690
標準ライブラリの奥深アップデートを掘り下げよう!
logica0419
2
420
[RSJ24] Object Segmentation from Open-Vocabulary Manipulation Instructions Based on Optimal Transport Polygon Matching with Foundation Models
keio_smilab
PRO
0
130
RAGHack: Building RAG apps in Python
pamelafox
0
120
四国のあのイベントの〇〇システムを45日間で構築した話 / cloudohenro2024_tachibana
biatunky
0
240
Featured
See All Featured
Web Components: a chance to create the future
zenorocha
308
41k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Embracing the Ebb and Flow
colly
83
4.4k
Debugging Ruby Performance
tmm1
72
12k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
34
1.9k
Designing on Purpose - Digital PM Summit 2013
jponch
113
6.8k
BBQ
matthewcrist
83
9.1k
Automating Front-end Workflow
addyosmani
1365
200k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
27
8.9k
Teambox: Starting and Learning
jrom
131
8.7k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
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