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.)

Popular Prag Prog topics Top

johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
ianwillie
Hello Brian, I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as...
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
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
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
foxtrottwist
Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New

Latest in PragProg

View all threads ❯