在做docker-compose时,无法在任何源(Bundler :: GemNotFound)中找到sprockets-3.6.2

时间:2016-07-03 11:53:29

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

我是码头工人的新手。我有一个现有的rails应用程序,我想将它停靠。请帮帮我,我该怎么解决这个问题。我遇到了这个问题。我在运行时发布了错误。

redis_1    | 1:M 03 Jul 11:47:39.087 * The server is now ready to accept connections on port 6379
sidekiq_1  | /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find sprockets-3.6.2 in any of the sources (Bundler::GemNotFound)
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `map!'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `materialize'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in `specs'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in `specs_for'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in `requested_specs'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in `requested_specs'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in `setup'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler.rb:127:in `setup'
sidekiq_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in `<top (required)>'
sidekiq_1  |    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
sidekiq_1  |    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
backend_1  | /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find sprockets-3.6.2 in any of the sources (Bundler::GemNotFound)
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `map!'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `materialize'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in `specs'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in `specs_for'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in `requested_specs'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in `requested_specs'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in `setup'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler.rb:127:in `setup'
backend_1  |    from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in `<top (required)>'
backend_1  |    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
backend_1  |    from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
backend_sidekiq_1 exited with code 1
backend_backend_1 exited with code 1

这是我的Gemfile

source 'https://rubygems.org'


gem 'unicorn', '~> 4.9'
gem 'pg', '~> 0.18.3'
gem 'sidekiq', '~> 4.0.1'
gem 'redis-rails', '~> 4.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

当我开始构建过程时,安装了sprockets-3.6.2

我的Dockerfile

# Use the barebones version of Ruby 2.2.3.
FROM ruby:2.2.3-slim

# Optionally set a maintainer name to let people know who made this image.
MAINTAINER Class and Objects <classandobjects@gmail.com>

# Install dependencies:
RUN apt-get update && apt-get install -qq -y build-essential nodejs libpq-dev postgresql-client-9.4 --fix-missing --no-install-recommends

# Set an environment variable to store where the app is installed to inside
# of the Docker image.
# CHANGE ALL INSTANCE OF 'backend' WITH YOUR PROJECT NAME
ENV INSTALL_PATH /backend
RUN mkdir -p $INSTALL_PATH

# This sets the context of where commands will be ran in and is documented
# on Docker's website extensively.
WORKDIR $INSTALL_PATH

# Ensure gems are cached and only get updated when they change. This will
# drastically increase build times when your gems do not change.
COPY Gemfile Gemfile
RUN bundle install

# Copy in the application code from your work station at the current directory
# over to the working directory.
COPY . .

# Provide dummy data to Rails so it can pre-compile assets.
RUN bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname SECRET_TOKEN=pickasecuretoken
#assets:precompile

# Expose a volume so that nginx will be able to read in assets in production.
VOLUME ["$INSTALL_PATH/public"]

# The default command that gets ran will be to start the Unicorn server.
CMD bundle exec unicorn -c config/unicorn.rb

我的docker-compose.yml

postgres:
  image: postgres:9.4.5
  environment:
    POSTGRES_USER: backend
    POSTGRES_PASSWORD: yourpassword
  ports:
    - '5432:5432'
  volumes:
    - backend-postgres:/var/lib/postgresql/data

redis:
  image: redis:3.0.5
  ports:
    - '6379:6379'
  volumes:
    - backend-redis:/var/lib/redis/data

backend:
  build: .
  links:
    - postgres
    - redis
  volumes:
    - .:/backend
  ports:
    - '8000:8000'
  env_file:
    - .backend.env

sidekiq:
  build: .
  command: bundle exec sidekiq -C config/sidekiq.yml
  links:
    - postgres
    - redis
  volumes:
    - .:/backend
  env_file:
    - .backend.env

我的sidekiq.rb

sidekiq_config = { url: ENV['JOB_WORKER_URL'] }

Sidekiq.configure_server do |config|
  config.redis = sidekiq_config
end

Sidekiq.configure_client do |config|
  config.redis = sidekiq_config
end

1 个答案:

答案 0 :(得分:1)

卷正在屏蔽图像中的目录。

volumes:
  - .:/backend

您正在使用当前目录中的文件覆盖容器路径/backend,这意味着您在bundle install期间安装的所有依赖项都不再存在。

您应该删除该卷,或运行docker-compose run backend bundle install以获取主机上的依赖关系。