我创建了一个虚拟应用
Rails new myapp --skip-test
然后向其添加一个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
每当我创建图像
docker build . # let's say the image id will be b2b0674325d1
然后我尝试运行服务器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).
有什么主意吗?
答案 0 :(得分:1)
我刚遇到这个问题。 您需要安装yarn和安装Rails应用程序所需的node_modules文件夹。 --check-files错误是由于package.json文件与丢失的yarn.lock文件之间不匹配所致。 https://classic.yarnpkg.com/en/docs/cli/check
将此添加到您的Dockerfile中将在您的Rails应用程序中安装yarn和缺少的node_modules
public class ProductEntityToProductDetailsDtoConverterImpl {
@Override
public ProductDetailsDto convert(Product product) {
return new ProductDetailsDto(
product.getId(),
product.getName()
);
}
}
虽然我们讨论的是锁文件,但是在尝试在开发中运行我的应用程序时遇到了一个问题。这是我发现有用的文章https://nickjanetakis.com/blog/dealing-with-lock-files-when-using-ruby-node-and-elixir-with-docker