Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Packaging and Shipping Rails Applications in Do...

Packaging and Shipping Rails Applications in Docker

You’re very happy as a Rails developer for drinking the Docker kool-aid. You just need to toss a Docker image to your Ops team and you're done! However, like all software projects, your Docker containers start to decay. Deployment takes days to occur as you download your gigantic Docker image to production. Everything’s on fire and you can’t launch the rails console inside your Docker container. Isn’t Docker supposed to take all these things away?
Engine Yard sponsored presentation at Railsconf 2016 (http://railsconf.com/program/sessions#prop_2166)

In this talk, I will discuss some Docker optimizations and performance tuning techniques to keep your Rails packaging and shipping pipeline in shape.

Allan Espinosa

May 05, 2016
Tweet

More Decks by Allan Espinosa

Other Decks in Technology

Transcript

  1. . ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── Rakefile ├──

    config.ru ├── app │ ├── assets │ │ └── ... │ ├── controllers │ │ └── ... │ ├── models │ │ ├── ... │ └── views │ └── ... └── ...
  2. $ docker build -t aespinosa/railsapp . Sending build context to

    Docker daemon 3.072 kB Step 1 : FROM ruby:2.2 ---> 8194a282d610 Step 2 : ADD . /app ---> f6698d506f88 Removing intermediate container 13078ea76192 Step 3 : WORKDIR /app ---> Running in a32412844f51 ---> 6608761a2632 Removing intermediate container a32412844f51 Step 4 : RUN bundle install ---> Running in 6492eb0f193b Fetching gem metadata from https://rubygems.org/.............. Fetching version metadata from https://rubygems.org/.. Resolving dependencies... Installing mini_portile2 2.0.0 Installing rack 1.6.4 Using bundler 1.11.2 Installing nokogiri 1.6.7.2 with native extensions Bundle complete! 2 Gemfile dependencies, 4 gems now installed. Bundled gems are installed into /usr/local/bundle. ---> b6833ef95104 Removing intermediate container 6492eb0f193b Step 5 : CMD "/app/bin/rails server" ---> Running in b9a83287aaee ---> 7d51adaf1672
  3. Back to Project Status Changes Console Output Edit Build Information

    Delete Build Git Build Data No Tags Docker Fingerprints Replay Pipeline Steps Next Build search Build #12 (Apr 29, 2016 9:00:58 AM) add description Started by anonymous user Revision: 798dbe54c3baa6fe77f45df50820ff0c31a3ccfd refs/remotes/origin/master Page generated: May 6, 2016 1:44:10 AM JST REST API Jenkins ver. 2.0-alpha-3 Started 6 days 16 hr ago Took 1 min 26 sec Jenkins LongBuild #12 ENABLE AUTO REFRESH Initial build
  4. Back to Project Status Changes Console Output Edit Build Information

    Delete Build Git Build Data No Tags Docker Fingerprints Replay Pipeline Steps Previous Build Next Build search Build #13 (Apr 29, 2016 10:17:38 AM) add description Started by anonymous user Revision: 798dbe54c3baa6fe77f45df50820ff0c31a3ccfd refs/remotes/origin/master Page generated: May 6, 2016 1:44:11 AM JST REST API Jenkins ver. 2.0-alpha-3 Started 6 days 15 hr ago Took 1.1 sec Jenkins LongBuild #13 ENABLE AUTO REFRESH Rebuild
  5. Step 1 : FROM ruby:2.2 ---> 8194a282d610 Step 2 :

    ADD . /app ---> Using cache ---> b69a81db78c3 Step 3 : WORKDIR /app ---> Using cache ---> f0599cf4359a Step 4 : RUN bundle install ---> Using cache ---> e02f0984472c Step 5 : CMD "/app/bin/rails server" ---> Using cache ---> fe6f97f6bf7b Successfully built fe6f97f6bf7b
  6. Back to Project Status Changes Console Output Edit Build Information

    Delete Build Git Build Data No Tags Docker Fingerprints Replay Pipeline Steps Previous Build search Build #14 (Apr 29, 2016 10:18:00 AM) add description Changes 1. Build (detail) Started by anonymous user Revision: 773689707fdb26bf2e2bb7850cf91df684cf124e refs/remotes/origin/master Page generated: May 6, 2016 1:44:13 AM JST REST API Jenkins ver. 2.0-alpha-3 Started 6 days 15 hr ago Took 1 min 24 sec Jenkins LongBuild #14 ENABLE AUTO REFRESH Same long build
  7. Step 1 : FROM ruby:2.2 ---> 8194a282d610 Step 2 :

    ADD . /app ---> a65c9a2d64eb Removing intermediate container cbfe5669ad3d Step 3 : WORKDIR /app ---> Running in 2427b73eac8e ---> 1efdd0eb9fdb Removing intermediate container 2427b73eac8e Step 4 : RUN bundle install ---> Running in 8616bef9cf30 Fetching gem metadata from https://rubygems.org/.............. Fetching version metadata from https://rubygems.org/.. Resolving dependencies... Installing mini_portile2 2.0.0 Installing rack 1.6.4 Using bundler 1.11.2 Installing nokogiri 1.6.7.2 with native extensions Bundle complete! 2 Gemfile dependencies, 4 gems now installed. Bundled gems are installed into /usr/local/bundle. ---> b4fa6a4dd2ac Removing intermediate container 8616bef9cf30 Step 5 : CMD "/app/bin/rails server" ---> Running in f74eed113754 ---> 482e16d4751d Removing intermediate container f74eed113754 Successfully built 482e16d4751d
  8. Build optimization FROM ruby:2.2 ADD Gemfile /app/Gemfile WORKDIR /app RUN

    bundle install ADD . /app CMD "/app/bin/rails server"
  9. Back to Project Status Changes Console Output Edit Build Information

    Delete Build Git Build Data No Tags Docker Fingerprints Replay Pipeline Steps Next Build search Build #3 (Apr 29, 2016 11:17:15 AM) add description Started by anonymous user Revision: 8f3fd364a8d461ceeb78e0e8a303780bca5983b5 refs/remotes/origin/master Page generated: May 6, 2016 1:44:10 AM JST REST API Jenkins ver. 2.0-alpha-3 Started 6 days 14 hr ago Took 1 min 28 sec Jenkins OptimizedBuild #3 ENABLE AUTO REFRESH
  10. Back to Project Status Changes Console Output Edit Build Information

    Delete Build Git Build Data No Tags Docker Fingerprints Replay Pipeline Steps Previous Build search Build #4 (Apr 29, 2016 12:14:05 PM) add description Changes 1. Build (detail) Started by anonymous user Revision: a5f685749b6178299dcc88bfc132216880fbd095 refs/remotes/origin/master Page generated: May 6, 2016 1:44:18 AM JST REST API Jenkins ver. 2.0-alpha-3 Started 6 days 13 hr ago Took 2 sec Jenkins OptimizedBuild #4 ENABLE AUTO REFRESH
  11. Dependencies cached Step 1 : FROM ruby:2.2 ---> 8194a282d610 Step

    2 : WORKDIR /app ---> Using cache ---> 224e3b91e357 Step 3 : ADD Gemfile /app/Gemfile ---> Using cache ---> 8db9245c0442 Step 4 : RUN bundle install ---> Using cache ---> 509d037aeb77 Step 5 : ADD . /app ---> d7bbd2ad37d2 Removing intermediate container 940d4a0e6090 Step 6 : CMD "/app/bin/rails server" ---> Running in c29b624574dd ---> f1a649fa6eff Removing intermediate container c29b624574dd Successfully built f1a649fa6eff