62118


EC2内でdocker buildを成功させたいです．  
詰まるところは毎回まちまちで  
\- nokogiri  
\- puma  
ここの２つのどちらかで詰まっている様子です．

その時のエラーが

[code]

    Fetching nokogiri 1.10.7
    Installing nokogiri 1.10.7 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    
        current directory: /usr/local/bundle/gems/nokogiri-1.10.7/ext/nokogiri
    /usr/local/bin/ruby -r ./siteconf20200109-10-m1jupr.rb extconf.rb
    Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200109-10-m1jupr.rb
    extconf.rb 2>&1
    
    Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.10.7 for
    inspection.
    Results logged to
    /usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.10.7/gem_make.out
    
    An error occurred while installing nokogiri (1.10.7), and Bundler cannot
    continue.
    Make sure that `gem install nokogiri -v '1.10.7' --source
    'https://rubygems.org/'` succeeds before bundling.
    
    In Gemfile:
      rails_admin was resolved to 2.0.1, which depends on
        rails was resolved to 5.2.4.1, which depends on
          actioncable was resolved to 5.2.4.1, which depends on
            actionpack was resolved to 5.2.4.1, which depends on
              actionview was resolved to 5.2.4.1, which depends on
                rails-dom-testing was resolved to 2.0.3, which depends on
                  nokogiri
    The command '/bin/sh -c gem install bundler && bundle install' returned a non-zero code: 5
    
[/code]

となっています．  
以下に，DockerfileとGemfileを載せておきます．  
よろしくお願いします．

Dockerfile

[code]

    FROM ruby:2.5.1
    ENV LANG C.UTF-8
    
    RUN apt-get update -qq && \
      apt-get install -y --no-install-recommends \
      build-essential \
      libpq-dev \
      nodejs
    
    ENV APP_DIR /project_name
    RUN mkdir -p $APP_DIR
    WORKDIR $APP_DIR
    
    COPY Gemfile $APP_DIR
    COPY Gemfile.lock $APP_DIR
    
    RUN gem install bundler && bundle install
    
    COPY . $APP_DIR
    
    COPY entrypoint.sh /usr/bin/
    RUN chmod +x /usr/bin/entrypoint.sh
    ENTRYPOINT ["entrypoint.sh"]
    EXPOSE 3000
    
    CMD ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]
    
[/code]

Gemfile

[code]

    source 'https://rubygems.org'
    git_source(:github) { |repo| "https://github.com/#{repo}.git" }
    
    ruby '2.5.1'
    
    gem 'rails', '~> 5.2.3'
    gem 'puma', '~> 3.11'
    gem 'sass-rails', '~> 5.0'
    gem 'uglifier', '>= 1.3.0'
    gem 'coffee-rails', '~> 4.2'
    gem 'jbuilder', '~> 2.5'
    gem 'bootsnap', '>= 1.1.0', require: false
    gem 'haml-rails'
    gem 'devise'
    gem 'omniauth'
    gem 'omniauth-facebook'
    gem 'dotenv-rails'
    gem 'rails_admin', '~> 2.0'
    gem 'cancancan'
    gem 'simple_form'
    gem 'cocoon', '1.2.12'
    gem 'momentjs-rails'
    gem 'gon'
    gem 'enum_help'
    gem 'mini_magick'
    gem 'aws-sdk-s3', require: false
    
    group :development, :test do
      gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
      gem 'rspec-rails'
      gem 'mysql2'
      gem 'capybara'
      gem 'selenium-webdriver'
      gem 'chromedriver-helper'
      gem 'rspec-rails'
      gem 'debase'
      gem 'ruby-debug-ide'
    end
    
    group :production do
      gem 'pg'
    end
    
    group :development do
      gem 'web-console', '>= 3.3.0'
      gem 'listen', '>= 3.0.5', '< 3.2'
      gem 'spring'
      gem 'spring-watcher-listen', '~> 2.0.0'
      gem 'better_errors'
      gem 'binding_of_caller'
      gem 'hirb'
      gem 'hirb-unicode'
      gem 'pry-byebug'
      gem 'pry-doc'
      gem 'pry-rails'
      gem 'pry-stack_explorer'
      gem 'rack-mini-profiler'
      gem 'bullet'
      gem 'rails_best_practices'
      gem 'annotate'
      gem "letter_opener"
      gem 'letter_opener_web'
    end
    
    group :test do
      gem 'rspec-rails'
      gem 'factory_bot_rails'
      gem 'database_rewinder'
      gem 'rspec-request_describer'
      gem 'autodoc'
      gem 'json_spec'
    end
    
    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
    
[/code]


CC BY-SA 4.0
2020-01-09T11:31:03.080
62105
2020-01-10T00:37:02.873
2020-01-09T12:13:44.507
2238
37390
question
ruby-on-rails
EC2内でdocker buildが成功しない


コメントにも投稿しましたが改めて。

エラーメッセージの先頭で "Cannot allocate memory" と出ているので、メモリの割り当てが足りていない可能性があります
(現象の発生がまちまちなのも恐らくこのため)。

設定状況を確認の上、メモリの割り当て量を追加してみてください。


CC BY-SA 4.0
2020-01-10T00:37:02.873
62118
2020-01-10T00:37:02.873
3060
62105
answer