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
610
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
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
240
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
950
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1k
💎のつくりかた 2023 / How to make gems 2023
sinsoku
2
260
Make tests run faster
sinsoku
2
530
YARD with RBS Syntax
sinsoku
1
310
Get started with OSS contributions
sinsoku
2
1k
Advice for Ruby beginners
sinsoku
2
410
継続的Railsアップグレード / Continuous Rails Upgrade
sinsoku
8
6.7k
Other Decks in Technology
See All in Technology
Proposal for a fictitious company presented by JAWS-UG DE&I team 'Naniwa Musume'
hiroramos4
PRO
0
120
[AWS Expert Online for JAWS-UG]AWS SAW を使ったトラブルシューティング効率化のススメ
furuton
0
170
ECS on FargateへのSeekable OCI導入レポート
iwamot
0
260
The Disturbing Truth: Why Do Most Software Projects Suck?
lemiorhan
0
110
「わたしたちのコード」を安定させるためにフレームワークとの距離を保つ / phperkaigi2024
blue_goheimochi
5
790
SmartHR プロダクトエンジニア求人ガイド 2024上期
smarthr
0
130
Beginner's Guide to Partitioning vs. Sharding in Postgres | Claire Giordano | Nordic PGDay 2024
clairegiordano
0
210
庁舎DX推進ガイドブック
senryakuka
0
1.7k
JaSST_Tokyo経験発表_20240313.pdf
ktanizaki
0
190
出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 「【速報】AWSの生成AIサービスであるAmazon Bedrock がリリースされたので朝イチで触ってみた」について語る
oshanqq
0
290
事業部を超えた 開発生産性向上に挑戦する
kentakozuka
2
130
スクラムマスター不在でスクラムをやるのは(とても辛いので)やめておけ! #scrumfukuoka
nulabinc
PRO
4
900
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
7
2.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
15
6.3k
Principles of Awesome APIs and How to Build Them.
keavy
119
16k
For a Future-Friendly Web
brad_frost
170
8.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
219
21k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
0
3.2k
Art, The Web, and Tiny UX
lynnandtonic
288
19k
Robots, Beer and Maslow
schacon
PRO
154
7.9k
Building Flexible Design Systems
yeseniaperezcruz
317
37k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
6
930
Rails Girls Zürich Keynote
gr2m
91
13k
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