
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 thenew
command to fail. (Notably,webpacker:install
doesn’t occur.) - p. 19 Update the
Dockerfile
to get a newer version of Ruby, a recent version ofyarn
, and set upwebpacker
: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
afterThe 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 installwebpacker
, since we installed it at the beginning. (There is no issue with the version ofnode
, either. In fact, running thecurl
to get an “up-to-date” version ends up installing a deprecated version.) You do need to install thewebpacker
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 therspec-rails
installation instructions. - p. 96-97 I had to
stop
,build
, andup -d --force-recreate
thewebpack_dev_server
after doing the same forweb
, after installing RSpec. - p. 100
gem 'capybara', '~> 3.34'
Most Liked

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

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

Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list)
Typo:...
New

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

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

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

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

Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64)
If you follow the defau...
New

On page 78 the following code appears:
<%= link_to ‘Destroy’, product,
class: ‘hover:underline’,
method: :delete,
data: { confirm...
New

When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New

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

What chair do you have while working… and why?
Is there a ‘best’ type of chair or working position for developers?
New

Any thoughts on Svelte?
Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New

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

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

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

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

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

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

Author Spotlight
Jamis Buck
@jamis
This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New

Author Spotlight:
Karl Stolley
@karlstolley
Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /react-native
- /sublime-text
- /textmate
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /lua
- /nodejs
- /julia
- /slackware
- /c
- /neovim