LoginSignup
2
4

More than 3 years have passed since last update.

docker-compose upの直後Yarnのエラーでコンテナが落ちる問題と解決

Posted at

環境

MacOS Mojave: 10.14.6
Docker: 19.03.8
Ruby: 2.6.6
Rails: 6.0.0
PostgreSQL

問題

RailsチュートリアルのSample_appを
Docker環境に移行している途中で

docker-compose upのあとpumaが起動した後すぐに以下のエラーを吐いて落ちる現象に遭遇

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

config/webpacker.ymlを編集する解決方法が見つかったがこれでは解決せず
yarnが原因でdocker-compose runが実行できないときの対処法 - Qiita

解決

こちらを参考にconfig/environments/development.rbconfig/webpacker.ymlを編集して解決しました
Running a Rails app with Webpacker and Docker - Dirk de Kok - Medium

Last configuration for Yarn and Webpacker

Rails does a lot of checkups on Yarn, a bit too much. Best is to disable this:

# config/environments/development.rb
config.webpacker.check_yarn_integrity = false

Also, we need to tell Rails that the webpacker server is running on the host webpacker and enable hot module reload. So set these values:

# config/webpacker.yml
development:
  dev_server:
    host: webpacker
    hmr: true

Last configuration for Yarn and Webpacker

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4