我尝试使用docker安装Rails,出现以下错误
Installing websocket-driver 0.6.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/usr/local/bundle/gems/websocket-driver-0.6.5/ext/websocket-driver
/usr/local/bin/ruby -r ./siteconf20180911-15-1atjs2q.rb extconf.rb
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20180911-15-1atjs2q.rb
extconf.rb 2>&1
Gem files will remain installed in /usr/local/bundle/gems/websocket-driver-0.6.5
for inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.5.0/websocket-driver-0.6.5/gem_make.out
An error occurred while installing websocket-driver (0.6.5), and Bundler cannot
continue.
Make sure that `gem install websocket-driver -v '0.6.5' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
rails was resolved to 5.1.6, which depends on
actioncable was resolved to 5.1.6, which depends on
websocket-driver
这是我的docker文件
FROM ruby:latest
RUN apt-get -y update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get -y update && apt-get -y install nodejs
RUN mkdir -p /app
WORKDIR /app
COPY . /app
RUN gem install rails
RUN /app/bin/setup
RUN chmod -R 755 /app
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb","-e","alpha"]
我尝试在我的Mac机器上安装其工作正常。我从数字海洋购买了新的ubuntu 16.04服务器,然后尝试安装该服务器。我得到这个错误。我正在使用Docker版本18.03.1-ce,内部版本9ee9f40。
在我的app / bin / setup中,我正在以下命令下运行
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Removing old tempfiles =="
system! 'bin/rails tmp:clear'
puts "\n== Precompiling Assets =="
system! 'bin/rails assets:precompile'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
我尝试使用ruby:latest,ruby:2.4.1无法正常工作。
在提出一些建议之后,我在Dockerfile中添加了sudo apt-get install ruby-dev,但这也不起作用
答案 0 :(得分:2)
无法分配内存-/ usr / local / bin / ruby -r ./siteconf20180911-15-1atjs2q.rb extconf.rb 2>&1
此行表明您的Digital Ocean drop没有足够的RAM来构建依赖关系,因此docker构建失败。
我遇到了同样的问题,不幸的是,您只需要更多的资源即可。
或者,您可以构建映像,标记并推入docker存储库,然后在DO Drop上拉并运行它,以避免构建步骤。
答案 1 :(得分:1)
使用高山版本的红宝石。它将占用更少的空间。例如:FROM ruby:2.5.1-alpine