Search code examples
ruby-on-railsdockeryarnpkg

Yarn packages out of date when running Rails app in Docker


I start my Rails 6 app as Docker containers, but when it starts the Rails server, it keeps giving the error:

warning Integrity check: System parameters don't match
website_1   | error Integrity check failed
website_1   | error Found 1 errors.
website_1   |
website_1   |
website_1   | ========================================
website_1   |   Your Yarn packages are out of date!
website_1   |   Please run `yarn install --check-files` to update.
website_1   | ========================================
website_1   |
website_1   |
website_1   | To disable this check, please change `check_yarn_integrity`
website_1   | to `false` in your webpacker config file (config/webpacker.yml).

So why is this not working? I have that command in the Dockerfile and also that check is disabled in webpacker.yml.

I build it with docker-compose up --build and then it doesn't seem to give errors. When I start it with docker-compose up, it will return the erorr when the Rails server is started. Here are the relevant files:

Dockerfile:

FROM ruby:2.6.5-slim

LABEL maintainer="John van Arkelen <johnvanarkelen@fastmail.com>"

RUN apt-get update -qq && apt-get install -y curl build-essential libpq-dev postgresql postgresql-contrib

RUN mkdir /app
RUN mkdir -p /usr/local/nvm
WORKDIR /app

RUN curl -sL https://deb.nodesource.com/setup_11.x | bash -
RUN apt-get install -y nodejs
RUN node -v
RUN npm -v

ENV BUNDLE_PATH /gems

RUN gem install bundler -v 2.0.2

COPY Gemfile Gemfile.lock package.json yarn.lock ./

RUN bundle install

RUN npm install -g yarn

COPY . /app

RUN yarn install --check-files

webpacker.yml:

default: &default
  source_path: app/javascript
  source_entry_path: packs
  public_root_path: public
  public_output_path: packs
  cache_path: tmp/cache/webpacker
  check_yarn_integrity: false
  webpack_compile_output: false

docker-compose.yml:

version: '2'

services:
  postgres:
    image: 'postgres:10.3-alpine'
    volumes:
      - 'postgres:/var/lib/postgresql/data'
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password123
      POSTGRES_DB: qd_development
    env_file:
      - '.env'

  redis:
    image: 'redis:4.0-alpine'
    command: redis-server --requirepass password123
    volumes:
      - 'redis:/data'

  website:
    depends_on:
      - 'postgres'
      - 'redis'
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    ports:
      - '3000:3000'
    volumes:
      - '.:/app'
      - gem_cache:/gems
    environment:
      DATABASE_HOST: postgres
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password123
      POSTGRES_DB: qd_development
    env_file:
      - '.env'

volumes:
  redis:
  postgres:
  gem_cache:





Solution

  • It seems to me like you are building your app correctly in the image in the /app directory. But afterward in your docker-compose you mount a local volume over your built /app directory, thereby losing your built /app folder contents. Try removing the mounted volume '.:/app'.