LoginSignup
1
0

More than 3 years have passed since last update.

Rails on Dockerのgemの永続化について

Posted at

背景

Dockerを利用したアプリ開発を行っていて、ログイン機能を搭載したくbcryptをGemfileに追加したが以下のエラーが出続け解決不能に。

22: from /usr/local/bundle/gems/spring-2.1.1/bin/spring:49:in `<main>'
        21: from /usr/local/bundle/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
        20: from /usr/local/bundle/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
        19: from /usr/local/bundle/gems/spring-2.1.1/lib/spring/client/server.rb:9:in `call'
        18: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        17: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        16: from /usr/local/bundle/gems/spring-2.1.1/lib/spring/server.rb:9:in `<top (required)>'
        15: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        14: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        13: from /usr/local/bundle/gems/spring-2.1.1/lib/spring/commands.rb:4:in `<top (required)>'
        12: from /usr/local/bundle/gems/spring-2.1.1/lib/spring/commands.rb:33:in `<module:Spring>'
        11: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        10: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
         9: from /usr/local/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'
         8: from /usr/local/lib/ruby/2.6.0/bundler.rb:107:in `setup'
         7: from /usr/local/lib/ruby/2.6.0/bundler/runtime.rb:20:in `setup'
         6: from /usr/local/lib/ruby/2.6.0/bundler/runtime.rb:108:in `block in definition_method'
         5: from /usr/local/lib/ruby/2.6.0/bundler/definition.rb:226:in `requested_specs'
         4: from /usr/local/lib/ruby/2.6.0/bundler/definition.rb:237:in `specs_for'
         3: from /usr/local/lib/ruby/2.6.0/bundler/definition.rb:170:in `specs'
         2: from /usr/local/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `materialize'
         1: from /usr/local/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `map!'
/usr/local/lib/ruby/2.6.0/bundler/spec_set.rb:91:in `block in materialize': Could not find bcrypt-3.1.16 in any of the sources (Bundler::GemNotFound)


解決方法


こちらのサイトの方法を試したが、一向に解決せず。。。
https://qiita.com/totto357/items/1741da83bf642dab99df


問題は実はDockerのgem一覧が永続化されていなかったからということが発覚。
https://nishinatoshiharu.com/datavolume-for-gem/

gemの永続化を行なっていないとコンテナ上でbundle installを実行してもDockerイメージにはgemが保存されないためエラーが発生していたようです。

gemを永続化していないと新しいgemを入れるたびに、ビルドを実行しコンテナを起動しなければならないというわけです。

しかし、永続化を行えばコンテナ上でgemをインストールした際にイメージの再ビルドを行わなくて済むということのようです。

永続化の方法については上記のサイトがわかりやすいため参照ください。

1
0
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
0