Reputation: 47
I tried installing Rails with docker, I got the below error
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
Here my docker file
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"]
I tried installing in my mac machine its working good. I bought a new ubuntu 16.04 server from the digital ocean and try installing the same. I got this error. I am using Docker version 18.03.1-ce, build 9ee9f40.
In my app/bin/setup I'm running below commands
#!/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
I tried with ruby:latest, ruby:2.4.1 nothing works.
After few suggestions I added sudo apt-get install ruby-dev in my Dockerfile but this also doesn't work
Upvotes: 0
Views: 1351
Reputation: 925
Use alpine version of ruby. It will consume much less space. For ex: FROM ruby:2.5.1-alpine
Upvotes: 1
Reputation: 562
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20180911-15-1atjs2q.rb extconf.rb 2>&1
This line indicates that your Digital Ocean droplet doesn't have enough RAM to build your dependencies and therefore the docker build fails.
I've had the same problem and unfortunately you just need more resources.
Alternatively you could build the image, tag and push it to a docker repository then pull and run it on your DO droplet to avoid the build step.
Upvotes: 3