尝试使用Docker部署rails4应用程序,我在以下Dockerfile中:
FROM ubuntu:14.04
RUN apt-get update && \
apt-get install -qy software-properties-common
RUN apt-add-repository -y ppa:brightbox/ruby-ng
RUN apt-get update && apt-get upgrade -y
# Ruby and dependencies
RUN apt-get install -qy curl nodejs libmysqlclient-dev libsqlite3-dev libpq-dev build-essential \
ruby2.2 ruby2.2-dev
RUN gem install bundler --no-ri --no-rdoc
# Cache bundle install
WORKDIR /tmp
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN bundle install --without development test
# Add rails project to project directory
ADD ./ /rails
# set WORKDIR
WORKDIR /rails
RUN bundle exec rake assets:precompile
# Cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Publish port 8080
EXPOSE 8080
在我的docker-compose.ml中,我的服务定义为使用此Dockerfile构建它
....
web:
build: .
....
但构建失败了:
service 'web' failed to build: The command '/bin/sh -c bundle exec rake assets:precompile' returned a non-zero code: 1
根据控制台,错误是:
---> Running in 32c12f52e507
/var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in
`block in materialize': Could not find debug_inspector-0.0.2 in any of
the sources (Bundler::GemNotFound)
我在Gemfile中添加了gem,
gem 'debug_inspector', '~> 0.0.2'
我将它捆绑并重建..现在又为另一个缺失的宝石引发了另一个错误:
var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in
`block in materialize': Could not find binding_of_caller-0.7.2 in any
of the sources (Bundler::GemNotFound)
我不明白发生了什么......我忘了避免这些重复错误的原因是什么?
感谢您的帮助
答案 0 :(得分:2)
在预编译资产之前添加RUN yarn install
可以在Rails 6应用程序上为我实现窍门。有道理,node_modules
不存在。
答案 1 :(得分:1)
我改变了我的Dockerfle
RUN bundle install --without development test
到
RUN bundle install
开发环境需要这些宝石......