【发布时间】:2018-09-11 10:42:33
【问题描述】:
我尝试使用 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 但这也不起作用
【问题讨论】:
标签: ruby-on-rails ruby docker rubygems bundler