FROM ruby:2.6
RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs
COPY . /usr/src/app/
WORKDIR /usr/src/app/
RUN bundle install
The Dockerfile instructs us to copy the current directory into /usr/src/app/. Placing our directory myapp into /usr/src/app/.
Then the WORKDIR is defined as /usr/src/app/
And RUN bundle install.
This fails as bundle install should be run in the app directory. We’re in /usr/src/app/ but we should be in /usr/src/app/myapp.
The Dockerfile is corrected with
FROM ruby:2.6
RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs
COPY . /usr/src/app/
WORKDIR /usr/src/app/myapp
RUN bundle install
I made the change you suggest, now get this:
/usr/local/bundle/gems/webpacker-4.3.0/lib/webpacker/configuration.rb:95:in `rescue in load’: Webpacker configuration file not found /usr/src/app/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /usr/src/app/config/webpacker.yml (RuntimeError)
Can anyone help? Frustrating to pay so much for a book that is incorrect.
I had this error when I was going through the book using Rails 6.1.
The problem is that the steps in the book don’t allow webpacker to be installed, and you’re seeing an error because its config file isn’t present.
I posted a topic about what I had to change to use Rails 6.1 here. It will fix your problem if you’re using Rails 6.1, and may fix it even if you’re using an older version of Rails.