简体   繁体   English

在 Docker 中运行 Rails 应用程序时,纱线包已过期

[英]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:我将我的 Rails 6 应用程序作为 Docker 容器启动,但是当它启动 Rails 服务器时,它不断给出错误:

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 .我在 Dockerfile 中有该命令,并且在webpacker.yml中禁用了该检查。

I build it with docker-compose up --build and then it doesn't seem to give errors.我用docker-compose up --build构建它,然后它似乎没有给出错误。 When I start it with docker-compose up , it will return the erorr when the Rails server is started.当我用docker-compose up启动它时,它会在 Rails 服务器启动时返回错误。 Here are the relevant files:以下是相关文件:

Dockerfile: 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: 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: 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:




It seems to me like you are building your app correctly in the image in the /app directory.在我看来,您正在 /app 目录中的图像中正确构建您的应用程序。 But afterward in your docker-compose you mount a local volume over your built /app directory, thereby losing your built /app folder contents.但是之后在您的 docker-compose 中,您在构建的 /app 目录上安装了一个本地卷,从而丢失了构建的 /app 文件夹内容。 Try removing the mounted volume '.:/app' .尝试删除已安装的卷'.:/app'

In your docker-compose.yml, you can also do this to avoid rebuilding everytime time.在您的 docker-compose.yml 中,您也可以这样做以避免每次都重新构建。 Then, you can just do docker-compose up然后,你可以做docker-compose up

command: bash -c "bundle install && yarn install --check-files && bundle exec rails s -p 3000 -b '0.0.0.0'"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复 Yarn 包在终端中过时 - How to fix Yarn packages are out of date in terminal 在 docker compose 上运行时无法连接到 rails 应用程序中的数据库 - Not able to connect to the db in rails app when running on docker compose 带有Rails App-Workers的Docker未运行 - Docker with a Rails App-Workers not running 调试使用vagrant运行docker的rails app - Debugging rails app running docker with vagrant 使用 yarn 推送到 Heroku Rails 应用程序时出现预编译错误 - Precompile error when push to Heroku Rails app with yarn 在 Heroku 下载 yarn 上部署 Rails 5 卡住消息“运行 buildpack Ruby 超时” - Deploy Rails 5 on Heroku download yarn gets stuck with message "Timed out running buildpack Ruby" 何时在Elastic Beanstalk中使用多容器Docker运行Rails应用程序? - When to use a multi-container docker in Elastic Beanstalk for running a Rails App? 运行 yarn build:docker 图像中的 css 时,我的目标文件夹为空 - My destenation folder is empty when running yarn build:css inside docker image 如何让 Rails 使用 Yarn 包中包含的图像/字体? - How to make Rails use images/fonts contained in Yarn packages? 在官方Ruby镜像的Docker容器上运行Rails应用时出错 - Error running rails app on docker container of official Ruby image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM