2

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:




Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
John
  • 6,404
  • 14
  • 54
  • 106

2 Answers2

6

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'.

wearego
  • 178
  • 10
  • So when you edit files during development, how do those changes get into your container? Do you rebuild the image every time? – partydrone Jul 13 '20 at 04:03
  • Yes, if you choose to put the source files into the image. Docker's caching combined with a good Dockerfile will make sure only the necessary build steps will be performed. (Copying the package.json and lock file first and installing it before adding the rest of your source code is usually the biggest quick win.) – wearego Jul 13 '20 at 15:09
2

In your docker-compose.yml, you can also do this to avoid rebuilding everytime time. Then, you can just do docker-compose up

command: bash -c "bundle install && yarn install --check-files && bundle exec rails s -p 3000 -b '0.0.0.0'"
sybind
  • 3,418
  • 5
  • 25
  • 25
  • I really like the solution by @sybind as it allows the developer to update their local and see those changes in the container. – paulmiller3000 Sep 23 '20 at 20:28