Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dockerfile cmd returns Yarn integrity error but Docker run works fine

I'm trying to get a Rails 6 application to run in Docker. When the command rails server is executed from the dockerfile, I get an error.

remote: web_1_a59d968487d2 | warning Integrity check: System parameters don't match
remote: web_1_a59d968487d2 | error Integrity check failed
remote: web_1_a59d968487d2 | error Found 1 errors.
remote: web_1_a59d968487d2 | 
remote: web_1_a59d968487d2 | 
remote: web_1_a59d968487d2 | ========================================
remote: web_1_a59d968487d2 |   Your Yarn packages are out of date!
remote: web_1_a59d968487d2 |   Please run `yarn install --check-files` to update.
remote: web_1_a59d968487d2 | ========================================
remote: web_1_a59d968487d2 | 
remote: web_1_a59d968487d2 | 
remote: web_1_a59d968487d2 | To disable this check, please change `check_yarn_integrity`
remote: web_1_a59d968487d2 | to `false` in your webpacker config file (config/webpacker.yml).
remote: web_1_a59d968487d2 | 
remote: web_1_a59d968487d2 | 
remote: web_1_a59d968487d2 | yarn check v1.16.0
remote: web_1_a59d968487d2 | info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

In my config/webpacker.yml file I have this line:

development:
  <<: *default
  check_yarn_integrity: false

In my config/environments/development.rb:

  config.webpacker.check_yarn_integrity = false

I am also building my node_modules as part of the docker setup (Dockerfile):

FROM ruby:2.6.3
RUN apt-get update && apt-get install apt-transport-https
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
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 nodejs yarn
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install

COPY . /myapp
RUN rm -Rf node_modules/
RUN rm yarn.lock
RUN yarn install

ENV RAILS_ENV=development
EXPOSE 3000

# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]

Running docker-compose run web rails s -b 0.0.0.0 works.

Running docker-compose up --build web returns the error.

like image 927
Andy Gauge Avatar asked May 14 '19 14:05

Andy Gauge


2 Answers

You can compare your Dockerfile+docker-compose.yml with this one and see if there is nay difference (like using RUN yarn install --check-files) which would make the error message disappear.

Another example (Dockerfile+docker-compose.yml) is used in "Running a Rails app with Webpacker and Docker" from Dirk de Kok

In both instances, the application is started with docker-compose up.
And they have followed, as you have, the recommendations of rails/webpacker issue 1568 (regarding config.webpacker.check_yarn_integrity = false in config/environments/development.rb)

like image 130
VonC Avatar answered Sep 17 '22 17:09

VonC


It worked today. No code was changed, it just decided to work. I tried running docker-compose run web rm -rf / to start over, but it ignored that command then started working. C'est la vie. @vonc thanks for the effort, I'll reward you.

Edit: It returned. This time I fixed it using

docker rm $(docker ps -a -q)

Warning: This destroys all your containers. Do not use this if you have data inside your volumes.

The cause of the problem was experimenting with creating a Dockerfile and the compose was not clearing out a layer of the volume. docker-compose run is different than docker-compose up because run creates a new layer on top of the docker volume to execute the command, essentially creating a new container. Docker itself was failing to apply the changes to an old layer.

like image 40
Andy Gauge Avatar answered Sep 20 '22 17:09

Andy Gauge