在Windows 10主机上启动Rails容器时找不到Gemfile或.bundle /目录

时间:2019-07-19 12:19:29

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

我在docker-compose网络中遇到了Rails容器的问题。几个月以来我都没有碰过它,当我本周尝试启动它时,它失败了。

当我尝试使用docker-compose up service启动容器时,启动失败并显示:

service_1  | Could not locate Gemfile or .bundle/ directory
support_portal_service_1 exited with code 10

两个文件都存在,主机是Windows 10计算机。

Bundle install成功完成:

Bundle complete! 19 Gemfile dependencies, 83 gems now installed.
Bundled gems are installed into `/usr/local/bundle`

我尝试过的事情:

  • 在缺少需求的情况下,将ruby和ruby-all-dev添加到apt-get安装中
  • ADD Gemfile /app/Gemfile更改为COPY Gemfile /app/Gemfile
  • 试图注释掉Gemfile.lock /app/Gemfile.lock
  • 在Windows 10主机上运行bundle install
  • 重建没有缓存的容器
  • 确保Docker可以访问驱动器/目录

这是我的Dockerfile

FROM ruby:2.5.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs default-libmysqlclient-dev ruby ruby-all-dev
RUN mkdir /app
WORKDIR /app
COPY Gemfile /app/Gemfile
#COPY Gemfile.lock /app/Gemfile.lock
WORKDIR /app
RUN bundle install
ADD . /app

还有我的docker-compose.yml

version: '2'
services:
  # Structured database
  sqldb:
    image: mysql:5.7
    volumes:
      - sql:/var/lib/mysql
    env_file:
      - .env
    environment:
      - MYSQL_USER=web
      - MYSQL_ROOT_PASSWORD=${PORTAL_DATABASE_PASSWORD}
      - MYSQL_PASSWORD=${PORTAL_DATABASE_PASSWORD}
    ports:
      - "3306:3306"

  # Application server
  service:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    volumes:
      - .:/app
    env_file:
      - .env
    expose:
      - "3000"
    depends_on:
      - sqldb

  # Front end proxy
  web:
    image: nginx
    build:
      context: .
      dockerfile: Dockerfile-web
    depends_on:
      - service
    ports:
      - "80:80"
      - "144:144"

# Persistence
volumes:
  sql:

0 个答案:

没有答案