I created a dummy app
Rails new myapp --skip-test
Then added a Dockerfile to it like this:
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
whenever I build an image
docker build . # let's say the image id will be b2b0674325d1
Then I try to run the server sudo docker run -p 3000:3000 b2b0674325d1 bin/rails s -b 0.0.0.0
I get this error
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
=> Run `rails server --help` for more startup options
sh: 1: yarn: not found
========================================
Your Yarn packages are out of date!
Please run `yarn install --check-files` to update.
========================================
To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).
Any idea?
I just came across this issue. You need to install yarn and install the node_modules folder required by a Rails application. The --check-files error is due to a mismatch between your package.json file and your missing yarn.lock file. https://classic.yarnpkg.com/en/docs/cli/check
Adding this to your Dockerfile will install yarn and the missing node_modules in your rails app
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | 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 -qq && apt-get install -y yarn
RUN yarn install
While we are on the subject of lockfiles, I came across an issue when trying to run my app in development. Here is an article that I found useful https://nickjanetakis.com/blog/dealing-with-lock-files-when-using-ruby-node-and-elixir-with-docker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With