Dockerfile cmd returns 纱线完整性错误但 Docker 运行 工作正常
Dockerfile cmd returns Yarn integrity error but Docker run works fine
我正在尝试在 Docker 中向 运行 申请 Rails 6。从 docker 文件执行命令 rails 服务器时,出现错误。
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.
在我的 config/webpacker.yml 文件中有这一行:
development:
<<: *default
check_yarn_integrity: false
在我的 config/environments/development.rb:
config.webpacker.check_yarn_integrity = false
我也在构建我的 node_modules 作为 docker 设置(Docker 文件)的一部分:
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"]
运行 docker-compose run web rails s -b 0.0.0.0
有效。
运行 docker-compose up --build web
returns 错误。
您可以将 Dockerfile
+docker-compose.yml
与 this one 进行比较,看看是否存在差异(例如使用 RUN yarn install --check-files
),这会使错误消息消失。
另一个例子(Dockerfile+docker-compose.yml
) is used in "Running a Rails app with Webpacker and Docker" from Dirk de Kok
在这两种情况下,应用程序都以 docker-compose up
启动。
和你一样,他们遵循了 rails/webpacker
issue 1568 的建议(关于 config/environments/development.rb
中的 config.webpacker.check_yarn_integrity = false
)
今天有效。没有更改代码,它只是决定工作。我尝试 运行ning docker-compose 运行 web rm -rf / 重新开始,但它忽略了该命令然后开始工作。这就是生活。 @vonc 谢谢你的努力,我会奖励你的。
编辑:它返回了。这次我使用
修复了它
docker rm $(docker ps -a -q)
警告:这会破坏你所有的容器。如果您的卷中有数据,请不要使用它。
问题的原因是尝试创建一个 Docker 文件,但撰写时没有清除卷的一层。 docker-compose run
与 docker-compose up
不同,因为 run
在 docker 卷之上创建了一个新层来执行命令,实质上是创建了一个新容器。 Docker 本身无法将更改应用到旧图层。
making config.webpacker.check_yarn_integrity = false
is not a good idea.
版本不兼容导致
尝试
rails webpacker:install
应该可以解决您的问题。
如果不试试
$ rm yarn.lock
$ yarn cache clean
$ yarn install
我正在尝试在 Docker 中向 运行 申请 Rails 6。从 docker 文件执行命令 rails 服务器时,出现错误。
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.
在我的 config/webpacker.yml 文件中有这一行:
development:
<<: *default
check_yarn_integrity: false
在我的 config/environments/development.rb:
config.webpacker.check_yarn_integrity = false
我也在构建我的 node_modules 作为 docker 设置(Docker 文件)的一部分:
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"]
运行 docker-compose run web rails s -b 0.0.0.0
有效。
运行 docker-compose up --build web
returns 错误。
您可以将 Dockerfile
+docker-compose.yml
与 this one 进行比较,看看是否存在差异(例如使用 RUN yarn install --check-files
),这会使错误消息消失。
另一个例子(Dockerfile+docker-compose.yml
) is used in "Running a Rails app with Webpacker and Docker" from Dirk de Kok
在这两种情况下,应用程序都以 docker-compose up
启动。
和你一样,他们遵循了 rails/webpacker
issue 1568 的建议(关于 config/environments/development.rb
中的 config.webpacker.check_yarn_integrity = false
)
今天有效。没有更改代码,它只是决定工作。我尝试 运行ning docker-compose 运行 web rm -rf / 重新开始,但它忽略了该命令然后开始工作。这就是生活。 @vonc 谢谢你的努力,我会奖励你的。
编辑:它返回了。这次我使用
修复了它docker rm $(docker ps -a -q)
警告:这会破坏你所有的容器。如果您的卷中有数据,请不要使用它。
问题的原因是尝试创建一个 Docker 文件,但撰写时没有清除卷的一层。 docker-compose run
与 docker-compose up
不同,因为 run
在 docker 卷之上创建了一个新层来执行命令,实质上是创建了一个新容器。 Docker 本身无法将更改应用到旧图层。
making
config.webpacker.check_yarn_integrity = false
is not a good idea.
版本不兼容导致
尝试
rails webpacker:install
应该可以解决您的问题。
如果不试试
$ rm yarn.lock
$ yarn cache clean
$ yarn install