
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

page 20: … protoc command…
I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New

This test is broken right out of the box…
— FAIL: TestAgent (7.82s)
agent_test.go:77:
Error Trace: agent_test.go:77
agent_test.go:...
New

The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New

Hi @Margaret ,
On page VII the book tells us the example and snippets will be all using Elixir version 1.11
But on page 3 almost the en...
New

I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps.
With:
ruby-3.0.0
s...
New

This is as much a suggestion as a question, as a note for others.
Locally the SGP30 wasn’t available, so I ordered a SGP40. On page 53, ...
New

When installing Cards as an editable package, I get the following error:
ERROR: File “setup.py” not found. Directory cannot be installe...
New

It seems the second code snippet is missing the code to set the current_user:
current_user: Accounts.get_user_by_session_token(session["...
New

AWDWR 7, page 152, page 153:
Hello everyone,
I’m a little bit lost on the hotwire part. I didn’t fully understand it.
On page 152 @rub...
New

root_layout: {PentoWeb.LayoutView, :root},
This results in the following following error:
no “root” html template defined for PentoWeb...
New
Other popular topics

Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New

No chair. I have a standing desk.
This post was split into a dedicated thread from our thread about chairs :slight_smile:
New

SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New

Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face:
Perhaps if there’s enough peop...
New

There’s a whole world of custom keycaps out there that I didn’t know existed!
Check out all of our Keycaps threads here:
https://forum....
New

I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New

Small essay with thoughts on macOS vs. Linux:
I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New

Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New

I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New

If you’re getting errors like this:
psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /react-native
- /vapor
- /v
- /wasm
- /django
- /security
- /nodejs
- /centos
- /rails
- /haskell
- /fable
- /swift
- /gleam
- /deno
- /js
- /tailwind
- /assemblyscript
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /c-plus-plus
- /flutter
- /actix
- /java
- /angular
- /ocaml
- /kubuntu
- /zig
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /emacs
- /nim
- /vuejs
- /nerves
- /elm