【问题标题】:The path `/app/include/engine` does not exist. (Bundler::PathError)路径“/app/include/engine”不存在。 (捆绑器::路径错误)
【发布时间】:2021-03-16 07:52:13
【问题描述】:

我正在使用可安装引擎对我的 rails 应用程序进行 dockerizing。但是我在运行图像The path `/app/include/engine` does not exist时经常遇到一个错误。

图像已成功构建,但在运行 docker-compose up 时会引发路径错误。

下面是我的Dockerfiledocker-compose.yml

Dockerfile

FROM ruby:2.4.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs

RUN mkdir /app

WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
COPY . .
RUN mkdir -p /app/include/engine
RUN git clone git@github.com:engine/engine.git /app/include/engine
RUN ls
RUN ls /app/include/engine
RUN DISABLE_SSL=true gem install puma -v 3.6.0
RUN bundle check ||  bundle install

CMD ["rails", "server", "-b", "0.0.0.0"]

docker-compose.yml

version: '2'
services:
  db: 
    image: mysql:8.0.21
    restart: always
    environment:
        MYSQL_ROOT_PASSWORD: root@123
        MYSQL_DATABASE: prod
        MYSQL_USER: root
        MYSQL_PASSWORD: root@123
    ports:
        - "3307:3306"
  app: 
    build:
      context: .
      dockerfile: Dockerfile
      args:
          SSH_PRIVATE_KEY: ${SSH_PRIVATE_KEY}
    volumes: 
        - ".:/app"
    ports: 
        - "3000:3000"
    depends_on:
        - db
    environment:
        key: value

我还在Gemfile 中包含了我的引擎路径,并遵循了安装引擎的所有步骤

# engine
gem 'api', path: 'include/engine'

它在本地环境中运行良好,但它在 docker 中给我一个错误。

有人可以帮助我在某处缺少什么吗?

【问题讨论】:

    标签: ruby-on-rails docker docker-compose bundler rails-engines


    【解决方案1】:

    因为这条线

      volumes: 
        - ".:/app"
    

    当开始覆盖图像中已有的现有数据时,这会将您的本地目录安装在容器内。这意味着 /app 中的所有内容都将替换为来自本地计算机的数据,包括您的引擎 /app/include/engine

    要解决此问题,您需要将此引擎克隆到本地文件夹中,以便在启动容器时可用。另一种选择是在/app 之外克隆引擎,例如在/tmp 或任何你喜欢的地方。

    【讨论】:

    • 所以如果我在 /app 之外克隆 docker-compose.yml 中的任何更改?
    • 不,只是重建图像并指向Gemfile中的新路径
    • 如果我在 /app 之外创建新目录 include/engine,为什么要更改 Gemfile 中的路径
    猜你喜欢
    • 2011-06-24
    • 2016-07-09
    • 1970-01-01
    • 2013-04-28
    • 2012-11-15
    • 1970-01-01
    • 2016-06-07
    • 2016-03-05
    • 1970-01-01
    相关资源
    最近更新 更多