お世話になっております。
下記の事象について知見がある方がいらっしゃいましたらご教示お願いします。
#起きている問題
AWS
環境でnginx
、unicorn
、mysql
をdockerコンテナ
で構築しdocker-compose build
で『Gem::Ext::BuildError: ERROR』が起きました。
$ docker-compose build Building db Step 1/4 : FROM mysql:8.0.17 ---> b8fd9553f1f0 Step 2/4 : RUN apt-get update && apt-get install -y apt-utils : : Fetching spring 2.0.2 Installing spring 2.0.2 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/nokogiri-1.10.9/ext/nokogiri /usr/local/bin/ruby -r ./siteconf20200529-6-18ba5hy.rb extconf.rb Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-18ba5hy.rb extconf.rb 2>&1 Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.10.9 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.10.9/gem_make.out An error occurred while installing nokogiri (1.10.9), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.10.9' --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 actionpack was resolved to 5.1.6, which depends on actionview was resolved to 5.1.6, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/nio4r-2.5.2/ext/nio4r /usr/local/bin/ruby -r ./siteconf20200529-6-t0ww9l.rb extconf.rb Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-t0ww9l.rb extconf.rb 2>&1 Gem files will remain installed in /usr/local/bundle/gems/nio4r-2.5.2 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/nio4r-2.5.2/gem_make.out An error occurred while installing nio4r (2.5.2), and Bundler cannot continue. Make sure that `gem install nio4r -v '2.5.2' --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 nio4r : : Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/byebug-9.0.6/ext/byebug /usr/local/bin/ruby -r ./siteconf20200529-6-1im7hf8.rb extconf.rb Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-1im7hf8.rb extconf.rb 2>&1 Gem files will remain installed in /usr/local/bundle/gems/byebug-9.0.6 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/byebug-9.0.6/gem_make.out An error occurred while installing byebug (9.0.6), and Bundler cannot continue. Make sure that `gem install byebug -v '9.0.6' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: byebug Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/kgio-2.11.3/ext/kgio /usr/local/bin/ruby -r ./siteconf20200529-6-h3dgyo.rb extconf.rb Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-h3dgyo.rb extconf.rb 2>&1 Gem files will remain installed in /usr/local/bundle/gems/kgio-2.11.3 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/kgio-2.11.3/gem_make.out An error occurred while installing kgio (2.11.3), and Bundler cannot continue. Make sure that `gem install kgio -v '2.11.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: unicorn was resolved to 5.4.1, which depends on kgio Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/mysql2-0.5.3/ext/mysql2 /usr/local/bin/ruby -r ./siteconf20200529-6-17zzo2d.rb extconf.rb Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-17zzo2d.rb extconf.rb 2>&1 Gem files will remain installed in /usr/local/bundle/gems/mysql2-0.5.3 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/mysql2-0.5.3/gem_make.out An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: mysql2 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/puma-3.9.1/ext/puma_http11 /usr/local/bin/ruby -r ./siteconf20200529-6-1wlltgf.rb extconf.rb Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-1wlltgf.rb extconf.rb 2>&1 Gem files will remain installed in /usr/local/bundle/gems/puma-3.9.1 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/puma-3.9.1/gem_make.out An error occurred while installing puma (3.9.1), and Bundler cannot continue. Make sure that `gem install puma -v '3.9.1' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: puma Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/raindrops-0.19.1/ext/raindrops /usr/local/bin/ruby -r ./siteconf20200529-6-1onovv5.rb extconf.rb Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-1onovv5.rb extconf.rb 2>&1 Gem files will remain installed in /usr/local/bundle/gems/raindrops-0.19.1 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux/2.5.0/raindrops-0.19.1/gem_make.out An error occurred while installing raindrops (0.19.1), and Bundler cannot continue. Make sure that `gem install raindrops -v '0.19.1' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: unicorn was resolved to 5.4.1, which depends on raindrops ERROR: Service 'app' failed to build: The command '/bin/sh -c bundle install -j4' returned a non-zero code: 5
#確認したこと
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20200529-6-18ba5hy.rb extconf.rb 2>&1
エラー文にメモリが解放できていないとエラーがでているのでDocker
のスナップショットを削除しました。
$ docker rm `docker ps -a -q`
問題は解決いたしませんでした。
#関連ファイル
Gemfile
$ cat Gemfile # frozen_string_literal: true source 'https://rubygems.org' gem 'bcrypt', '3.1.12' gem 'bootstrap-sass', '3.3.7' gem 'bootstrap-will_paginate', '1.0.0' gem 'carrierwave', '~> 1.3', '>= 1.3.1' gem 'coffee-rails', '4.2.2' gem 'faker', '1.7.3' gem 'geocoder' gem 'gmaps4rails' gem 'jbuilder', '2.7.0' gem 'jquery-rails', '4.3.1' gem 'jquery-ui-rails' gem 'pry-rails' gem 'puma', '3.9.1' gem 'rails', '5.1.6' gem 'rails-i18n' gem 'ransack' gem 'rubocop', require: false gem 'rubocop-rails', require: false gem 'sass-rails', '5.0.6' gem 'turbolinks', '5.0.1' gem 'uglifier', '3.2.0' gem 'will_paginate', '3.1.6' gem 'mysql2' gem 'dotenv-rails' group :development, :test do # gem 'sqlite3', '1.3.13' gem 'byebug', '9.0.6', platform: :mri end group :development do gem 'listen', '3.1.5' gem 'spring', '2.0.2' gem 'spring-watcher-listen', '2.0.1' gem 'web-console', '3.5.1' end group :test do gem 'guard', '2.13.0' gem 'guard-minitest', '2.4.4' gem 'minitest', '5.10.3' gem 'minitest-reporters', '1.1.14' gem 'rails-controller-testing', '1.0.2' end group :production, :staging do gem 'unicorn', '5.4.1' end
docker-compose.yml
version: '2' services: app: build: context: . dockerfile: ./docker/rails/Dockerfile command: bundle exec unicorn -p 3000 -c /app/config/unicorn.rb # command: bundle exec rails s -p 3000 -b '0.0.0.0' ports: - '3000:3000' volumes: - /var/tmp - .:/coffee_app depends_on: - db extends: file: ./docker/mysql/password.yml service: password db: build: context: . dockerfile: ./docker/mysql/Dockerfile ports: - '3306:3306' volumes: - db_data:/var/lib/mysql extends: file: ./docker/mysql/password.yml service: password nginx: build: context: . dockerfile: ./docker/nginx/Dockerfile ports: - '80:80' volumes: - coffee_app volumes: db_data:
#環境
ruby 2.5.1
rails 5.1.6
docker version 19.03.6
docker-compose version 1.24.0
回答1件
あなたの回答
tips
プレビュー