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'
9 1170 1

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

abtin
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...
14 2914 7
New
jimmykiang
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:...
4 1547 7
New
jamis
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...
4 2350 3
New
herminiotorres
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...
15 1541 13
New
JohnS
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...
0 1272 3
New
fynn
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, ...
0 1284 2
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
0 1716 1
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
0 1878 8
New
mert
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...
0 1223 4
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
8 1084 4
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1016 16836 371
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
177 8408 77
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
30 3341 14
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
236 5547 90
New
AstonJ
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....
15 7818 20
New
AstonJ
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...
14 7500 9
New
dimitarvp
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...
166 7371 70
New
wmnnd
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 ...
37 2492 15
New
Help
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...
8 3188 4
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
1 1274 1
New

Latest in PragProg

View all threads ❯