med*_*zid 7 ruby-on-rails docker
我创建了一个虚拟应用程序
Rails new myapp --skip-test
Run Code Online (Sandbox Code Playgroud)
然后向其中添加一个 Dockerfile,如下所示:
FROM ruby:2.6
RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN bundle install
Run Code Online (Sandbox Code Playgroud)
每当我构建图像时
docker build . # let's say the image id will be b2b0674325d1
Run Code Online (Sandbox Code Playgroud)
然后我尝试运行服务器sudo docker run -p 3000:3000 b2b0674325d1 bin/rails s -b 0.0.0.0
我收到这个错误
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
=> Run `rails server --help` for more startup options
sh: 1: yarn: not found
========================================
Your Yarn packages are out of date!
Please run `yarn install --check-files` to update.
========================================
To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).
Run Code Online (Sandbox Code Playgroud)
任何想法?
小智 8
我刚刚遇到这个问题。您需要安装yarn并安装Rails应用程序所需的node_modules文件夹。--check-files 错误是由于您的 package.json 文件和丢失的yarn.lock 文件不匹配造成的。 https://classic.yarnpkg.com/en/docs/cli/check
将其添加到您的 Dockerfile 将在您的 Rails 应用程序中安装 Yarn 和缺少的 Node_modules
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 yarn
RUN yarn install
Run Code Online (Sandbox Code Playgroud)
当我们讨论锁定文件的主题时,我在尝试运行开发中的应用程序时遇到了一个问题。这是我发现有用的文章https://nickjanetakis.com/blog/dealing-with-lock-files-when-using-ruby-node-and-elixir-with-docker
| 归档时间: |
|
| 查看次数: |
13261 次 |
| 最近记录: |