edruder

edruder

Docker for Rails Developers: Notes for Rails 6.1, Ruby 2.7.2

I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here.

  • p. 11 rails new myapp --skip-test. Do not add the --skip-bundle flag–it causes several steps of the new command to fail. (Notably, webpacker:install doesn’t occur.)
  • p. 19 Update the Dockerfile to get a newer version of Ruby, a recent version of yarn, and set up webpacker:
    FROM ruby:2.7.2
    
    # Ensure latest packages for Yarn
    RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true apt-key add -
    RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
    
    RUN apt-get update -yqq
    RUN apt-get install -yqq --no-install-recommends nodejs yarn
    
    WORKDIR /usr/src/app
    
    COPY . .
    
    RUN bundle install
    RUN yarn install
    
  • p. 40 Modified Dockerfile after The Gemfile Caching Trick:
    FROM ruby:2.7.2
    
    # Ensure latest packages for Yarn
    RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true apt-key add - && \
        echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
        apt-get update -yqq && apt-get install -yqq --no-install-recommends \
          nodejs \
          yarn
    
    WORKDIR /usr/src/app
    
    COPY Gemfile* ./
    
    RUN bundle install
    RUN yarn install
    
    COPY . .
    
    CMD ["bin/rails", "s", "-b", "0.0.0.0"]
    
  • p. 88 In Rails JavaScript Front End with Webpacker, nothing needs to be done to install webpacker, since we installed it at the beginning. (There is no issue with the version of node, either. In fact, running the curl to get an “up-to-date” version ends up installing a deprecated version.) You do need to install the webpacker React integration, though–docker-compose run web bin/rails webpacker:install:react.
  • p. 96 Setting Up RSpec, grab a newer version of RSpec–gem 'rspec-rails', '~> 4.0.1'–per the rspec-rails installation instructions.
  • p. 96-97 I had to stop, build, and up -d --force-recreate the webpack_dev_server after doing the same for web, after installing RSpec.
  • p. 100 gem 'capybara', '~> 3.34'

Most Liked

edruder

edruder

  • p. 146 With Rails 6, there’s a new way to handle secrets. Instead of defining SECRET_KEY_BASE, you’ll need to define RAILS_MASTER_KEY.
    1. Run bin/rails credentials:edit and save the result. This will create the value of an encryption key in config/master.key and an encrypted secrets file in config/credentials.yml.enc.
    2. Copy the value of the encryption key in config/master.key to the RAILS_MASTER_KEY environment variable in .env/production/web. (SECRET_KEY_BASE is obsolete–don’t define it.)

Where Next?

Popular Pragmatic Bookshelf topics Top

jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=> (create-migration "guestbook") Execution error (Ill...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
leba0495
Hello! Thanks for the great book. I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
nicoatridge
Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New
NewsBot
A new openSUSE blog post/announcement has been posted! Get the full details here: https://news.opensuse.org/2025/06/03/speakers-set-cou...
New

Sub Categories:

OSZAR »