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 Pragmatic Bookshelf topics Top

belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
rainforest
Hi, I’ve got a question about the implementation of PubSub when using a Phoenix.Socket.Transport behaviour rather than channels. Before ...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
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...
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
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
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
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
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