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
docker for rubyists
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Bryce "BonzoESC" Kerley
October 17, 2017
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
docker for rubyists
miamirb 10/16/2017
Bryce "BonzoESC" Kerley
October 17, 2017
More Decks by Bryce "BonzoESC" Kerley
See All by Bryce "BonzoESC" Kerley
Ruby in 2020
bryce
1
130
Rails and the Internet of Things
bryce
1
87
It's Not Ruby, But…
bryce
0
83
Ruby 2.5: What's New and What's Cool
bryce
0
90
Would You Like To Make A Game?
bryce
0
65
WebSockets and ActionCable
bryce
0
95
How I Learned to Stop Worrying and Like RSpec
bryce
0
87
How Do Computers Even Work?
bryce
1
220
Growing Distributed Systems: Abril Pro Ruby
bryce
0
59
Other Decks in Programming
See All in Programming
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
200
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
640
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
250
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
180
AutonomyとControlのあいだ:Graflowで記述するAIエージェント協調
myui
0
110
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
490
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.2k
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
250
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.2k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
5.1k
Agentic UI
manfredsteyer
PRO
0
130
dRuby over BLE
makicamel
2
330
Featured
See All Featured
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
240
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Designing for Performance
lara
611
70k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
300
It's Worth the Effort
3n
188
29k
Bash Introduction
62gerente
615
210k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
The Curious Case for Waylosing
cassininazir
1
380
Six Lessons from altMBA
skipperchong
29
4.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
270
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
530
Transcript
Docker for Rubyists Miami Ruby Brigade Oct. 16, 2017
Rails in 2005 • Compile Ruby from source • Install
Rubygems separately • Choose your own adventure: • CGI (slow) • FastCGI (quite miserable to set up) • App server (fast, low-grade miserable to set up) • Configure database • Figure out gem dependencies
Rails in 2017 • Choose your own install Ruby adventure
• rbenv • chruby • rvm • PPA • source • Configure database • Install dependencies
Better, Not Great • lotta configuration • need to script
it • ideally dev and prod are same
Configuration Management • Makes setting stuff up repeatable • Good
for production • Less-good for development
Vagrant • Makes setting up a VM repeatable • Good
but slow for development • Less common in production
Docker • Good for development • Good and common in
production • Plenty fast • Lots of work is done
Let's Dockerize Greatjobify
None
Greatjobify • Sinatra • ImageMagick
Greatjobify 1. Pick base image 2. Add OS packages 3.
Create and change to app directory 4. Add Gemfile and Gemfile.lock 5. Bundle 6. Add rest of app 7. Run it
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"]
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] Base image
None
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] OS packages
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] Create and change to app directory
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] Add Gemfile and Gemfile.lock
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] Bundle
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] Add rest of the app
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] Declare a listening port
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"] Command to run
Dockerfile FROM ruby:2.4.1 RUN apt-get update -qq && \
apt-get install -y build-essential imagemagick RUN mkdir /greatjobify WORKDIR /greatjobify ADD Gemfile* /greatjobify/ RUN bundle install ADD . /greatjobify EXPOSE 9292 CMD ["unicorn", "-p", "9292"]
Building the Image docker build -t greatjobify . Name it
"greatjobify"
None
None
And there it is
Running it docker run --rm -p 9292:9292 -it greatjobify Remove
the instance afterwards Forward instance port 9292 to host port 9292 Keep stdio open and hook it up here The image to run
tfw you don't update your apps more than a couple
times per decade
None
None
External Services greatjobify has an optional dependency on memcache
External Services • Instances can run multiple processes • Instances
should be single-purpose • Horizontal scalability • Orchestrate several instances to work together
Docker Compose "Orchestration"
docker-compose.yml • Describe each instance that you need • base
image or build directory • mounted volumes • dependencies • open ports • commands • environment variables
None
web.rb (snippet) memcache_address = ENV['MEMCACHIER_SERVERS'] || 'localhost:11211' memcache =
[ memcache_address, { username: ENV['MEMCACHIER_USERNAME'] || nil, password: ENV['MEMCACHIER_PASSWORD'] || nil } ] dalli = Dalli::Client.new *memcache use Rack::Cache, :metastore => dalli, :entitystore => dalli
docker-compose.yml • Web service • Build the current directory •
Expose 9292 • Depend on memcached service • Set MEMCACHIER_SERVERS environment variable • Memcached service • Use the "memcached" image
docker-compose.yml version: '3' services: web: build: .
ports: - "9292:9292" depends_on: - memcached environment: - MEMCACHIER_SERVERS=memcached memcached: image: memcached
Running It docker-compose up
None
None
None
None
None
Rails App • Similar to Sinatra • Web process •
Db processes • Support processes • Database console • App console
Docker in Production • Google Container Engine • AWS Elastic
beanstalk • Heroku Container Registry
Docker in Production • Docker Swarm • Kubernetes