无法通过docker compose找到Gemfile错误

时间:2017-02-26 11:22:53

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

我在docker-compose up命令

时收到错误消息

我的Dockerfile:

FROM ruby:2.3

RUN apt-get update -yqq \
  && apt-get install -yqq --no-install-recommends \
    postgresql-client \
    nodejs \
  && apt-get -q clean 


# Pre-install gems with native extensions
RUN bundle update nokogiri
RUN gem install nokogiri -v "1.6.8.1"

WORKDIR /usr/src/app
COPY Gemfile* .
RUN bundle install
COPY . .

CMD script/start

我的docker-compose.yml:

version: "2"

volumes:
  db-data:
    external: false

services:
  db:
    image: postgres
    env_file: .env
    volumes:
      - db-data:/var/lib/postgresql/db-data

  app:
    build: .
    env_file: .env
    volumes:
      - .:/usr/src/app
    ports:
      - "3000:3000"
    depends_on:
      - db

我的gemfile:

source 'https://rubygems.org'
ruby '2.3'
gem 'rails', '4.2.2'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
#gem 'fog', '1.26.0'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
gem 'mailboxer'
gem 'therubyracer', platforms: :ruby
gem 'unicorn'
group :development, :test do

#gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
gem 'rake', '11.2.2'
gem 'font-awesome-rails', '~> 4.1.0.0'
gem 'nokogiri', '~> 1.6.8'

end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '2.11.1'
end

group :development, :test do
  #gem 'better_errors'
  gem 'sqlite3'
  gem 'pry-rails'
  gem 'pry-nav'
  gem 'meta_request'
  gem 'capistrano', '~> 3.4.1'

  gem 'capistrano-bundler', '~> 1.1.2'
  gem 'capistrano-rails', '~> 1.1.1'
  gem 'capistrano-ssh-doctor', '~> 1.0'
  gem 'net-ssh', '~> 2.0'
  gem 'byebug', '3.4.0'
  # Add this if you're using rbenv
  #gem 'capistrano-rbenv', github: "capistrano/rbenv"
end

我想提一下,我在我的rails app文件夹中运行chmod -R 777 .。 我得到的错误是:

Could not locate Gemfile
ERROR: Service 'app' failed to build: The command '/bin/sh -c bundle update nokogiri' returned a non-zero code: 10

1 个答案:

答案 0 :(得分:0)

你的Dockerfile中有:

RUN bundle update nokogiri
RUN gem install nokogiri -v "1.6.8.1"

因为没有安装,所以无法更新nokogiri gem。你还要在下一行安装它。您可能希望删除RUN bundle update nokogiri或重新考虑如何更好地使用它。