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 Rails engineers
Search
Takumi Shotoku
December 02, 2021
Technology
0
660
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
310
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
290
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1.1k
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1.2k
💎のつくりかた 2023 / How to make gems 2023
sinsoku
2
290
Make tests run faster
sinsoku
2
590
YARD with RBS Syntax
sinsoku
1
410
Get started with OSS contributions
sinsoku
2
1.1k
Advice for Ruby beginners
sinsoku
2
450
Other Decks in Technology
See All in Technology
成長期に歩みを止めないための創業期の開発文化形成
mayah
6
420
Azure OpenAI Service Dev Day / LLMでできる!使える!生成AIエージェント
masahiro_nishimi
3
800
[NIKKEI Tech Talk] KDDI/KAG Scrum & Community for Engineering Training
curanosuke
2
220
AWSで”最小権限の原則”を実現するための考え方 /20240722-ssmjp-aws-least-privilege
opelab
10
4.4k
Github Actions 로 Android 팀의 효율성 극대화
hadonghyun
0
160
Git 研修 Advanced【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
200
可視化プラットフォームGrafanaの基本と活用方法の全て
hamadakoji
0
230
ソフトウェアエンジニアリングの知見を活かして データ基盤をいい感じにする on Snowflake [MIERUNE BBQ #10]
mtpooh
2
150
DDDにおける認可の扱いとKotlinにおける実装パターン / authorization-for-ddd-and-kotlin-implement-pattern
urmot
4
390
Flutter研修【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
160
サービス開発を前に進めるために 新米リードエンジニアが 取り組んだこと / Steps Taken by a Novice Lead Engineer to Advance Service Development
nologyance
0
180
VPoEの視点から見た、ヘンリーがサーバーサイドKotlinを使う理由 / Why Server-side Kotlin 2024
cho0o0
1
420
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
44
4.7k
Designing for Performance
lara
604
67k
5 minutes of I Can Smell Your CMS
philhawksworth
200
19k
Leading Effective Engineering Teams 2024
addyosmani
3
300
The Invisible Side of Design
smashingmag
294
50k
Become a Pro
speakerdeck
PRO
15
4.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
23
1.9k
Fontdeck: Realign not Redesign
paulrobertlloyd
79
5.1k
GraphQLとの向き合い方2022年版
quramy
36
13k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
360
22k
The Illustrated Children's Guide to Kubernetes
chrisshort
39
47k
Clear Off the Table
cherdarchuk
89
320k
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