LoginSignup
1
1

More than 3 years have passed since last update.

Vagrant&DockerのRailsの開発環境構築 メモ

Posted at

開発環境
Winodows 1p Pro (64bit)
Vagrant 2.2.14
Ubuntu 16.04.6 LTS
Docker 18.09.7
ruby:ruby 2.7.2p137
/rails_docker
Dockerの勉強の為、Railsの開発環境構築を構築しました。
Vagrantフォルダ配下にrails_dockerディレクトリを置きその下に、Docker,docker-compose-ymlを配置。
さらに下にsrcディレクトリ置き、Gemfileを配置。
sudo docker-compose run web rails new . --force --database=mysql コマンドを実行したら以下のエラーが発生した。
````

Building web
ERROR: Error processing tar file(signal: killed):

ソースを修正しながら再度インストールを実行。すると次のエラーが・・・・。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/racc-1.5.2/ext/racc/cparse
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.7.0 -r
./siteconf20210122-7-k0z1kz.rb extconf.rb
extconf failedCannot allocate memory - /usr/local/bin/ruby

Gem files will remain installed in /usr/local/bundle/gems/racc-1.5.2 for
inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.7.0/racc-1.5.2/gem_make.out

An error occurred while installing racc (1.5.2), and Bundler cannot continue.
Make sure that `gem install racc -v '1.5.2' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  rails was resolved to 6.1.1, which depends on
    actioncable was resolved to 6.1.1, which depends on
      actionpack was resolved to 6.1.1, which depends on
        actionview was resolved to 6.1.1, which depends on
          rails-dom-testing was resolved to 2.0.3, which depends on
            nokogiri was resolved to 1.11.1, which depends on
              racc
ERROR: Service 'web' failed to build: The command '/bin/sh -c bundle config --local set path 'vendor/bundle'   && bundle install' returned a non-zero code: 5

「extconf failedCannot allocate memory」というメッセージが.
メモリ不足の可能性を教えてもらい。
VSCodeの中、Vagrant に SSH-FS 接続よりいい方法があるかな?を参考にして、Vagrantファイルにメモリーを増やしました。

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64" # Ubuntu 16.04 を使用
  #config.vm.network "forwarded_port", guest: 3000, host: 3000 # Railsで利用するポートを設定
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "4096" # メモリを多めに設定

  end
end

環境を構築して再度実行したら、無事インストール完了しました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1