Ruby on rails 使用Docker安装Rails捆绑包失败
我试着用docker安装Rails,我得到了以下错误Ruby on rails 使用Docker安装Rails捆绑包失败,ruby-on-rails,ruby,docker,rubygems,bundler,Ruby On Rails,Ruby,Docker,Rubygems,Bundler,我试着用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/b
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电脑上,效果很好。我从digital ocean购买了一台新的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,但这也不起作用
无法分配内存-/usr/local/bin/ruby-r./siteconf20180911-15-1atjs2q.rb
extconf.rb 2>&1
这一行表示您的Digital Ocean droplet没有足够的RAM来构建依赖项,因此docker构建失败
我也有同样的问题,不幸的是,你只需要更多的资源
或者,您可以构建图像,标记并将其推送到docker存储库,然后在DO droplet上拉取并运行它,以避免构建步骤
无法分配内存-/usr/local/bin/ruby-r./siteconf20180911-15-1atjs2q.rb
extconf.rb 2>&1
这一行表示您的Digital Ocean droplet没有足够的RAM来构建依赖项,因此docker构建失败
我也有同样的问题,不幸的是,你只需要更多的资源
或者,您可以构建映像,标记并将其推送到docker存储库,然后在DO droplet上拖动并运行它,以避免构建步骤。使用alpine版本的ruby。它将占用更少的空间。例如:ruby:2.5.1-alpine的
使用ruby的alpine版本。它将占用更少的空间。例如:ruby:2.5.1-alpine的
这是一个不幸的答案,我也遇到了这个问题。在升级整个液滴之前,请检查内存中还有哪些内容。对我来说,这是当前运行puma
web服务器和其他东西的docker容器。您可以使用top
分析内存使用情况(按shift+
一次,按MEM%
排序)。在bundle
中开始的项目可能是从bundle exec
开始的ruby进程。我停止了容器,重建了它,它成功了。在构建过程中,我将此作为每秒捕获可用内存的廉价方法运行:whilesleep 1;执行cat/proc/meminfo | grep MemFree>>~/out;完成
这是一个不幸的答案,我也遇到了这个问题。在升级整个液滴之前,请检查内存中还有哪些内容。对我来说,这是当前运行puma
web服务器和其他东西的docker容器。您可以使用top
分析内存使用情况(按shift+
一次,按MEM%
排序)。在bundle
中开始的项目可能是从bundle exec
开始的ruby进程。我停止了容器,重建了它,它成功了。在构建过程中,我将此作为每秒捕获可用内存的廉价方法运行:whilesleep 1;执行cat/proc/meminfo | grep MemFree>>~/out;完成