Ruby3.1 ~ 3.4でDocker buildでpsychのインストールで失敗する

## 起こったこと
2025/01/15に突如Docker buildが動かなくなった。(Rubyのバージョンは3.4.1)
利用していたのはruby-slimのイメージになります

※ 正確にはdevelop mergeでstgに自動リリースしていたのがデプロイ失敗するようになりました。

```bash
#18 110.8 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
#18 110.8 
#18 110.8     current directory: /bundle/ruby/3.4.0/gems/psych-5.2.2/ext/psych
#18 110.8 /usr/local/bin/ruby extconf.rb
#18 110.8 checking for pkg-config for yaml-0.1... not found
#18 110.8 checking for yaml.h... no
#18 110.8 yaml.h not found
#18 110.8 *** extconf.rb failed ***
#18 110.8 Could not create Makefile due to some reason, probably lack of necessary
#18 110.8 libraries and/or headers.  Check the mkmf.log file for more details.  You may
#18 110.8 need configuration options.
#18 110.8 
#18 110.8 Provided configuration options:
#18 110.8 	--with-opt-dir
#18 110.8 	--without-opt-dir
#18 110.8 	--with-opt-include=${opt-dir}/include
#18 110.8 	--without-opt-include
#18 110.8 	--with-opt-lib=${opt-dir}/lib
#18 110.8 	--without-opt-lib
#18 110.8 	--with-make-prog
#18 110.8 	--without-make-prog
#18 110.8 	--srcdir=.
#18 110.8 	--curdir
#18 110.8 	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
#18 110.8 	--with-libyaml-source-dir
#18 110.8 	--without-libyaml-source-dir
#18 110.8 	--with-yaml-0.1-dir
#18 110.8 	--without-yaml-0.1-dir
#18 110.8 	--with-yaml-0.1-include=${yaml-0.1-dir}/include
#18 110.8 	--without-yaml-0.1-include
#18 110.8 	--with-yaml-0.1-lib=${yaml-0.1-dir}/lib
#18 110.8 	--without-yaml-0.1-lib
#18 110.8 	--with-yaml-0.1-config
#18 110.8 	--without-yaml-0.1-config
#18 110.8 	--with-pkg-config
#18 110.8 	--without-pkg-config
#18 110.8 	--with-libyaml-dir
#18 110.8 	--without-libyaml-dir
#18 110.8 	--with-libyaml-include=${libyaml-dir}/include
#18 110.8 	--without-libyaml-include
#18 110.8 	--with-libyaml-lib=${libyaml-dir}/lib
#18 110.8 	--without-libyaml-lib
#18 110.8 
#18 110.8 To see why this extension failed to compile, please check the mkmf.log which can
#18 110.8 be found here:
#18 110.8 
#18 110.8   /bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/psych-5.2.2/mkmf.log
#18 110.8 
#18 110.8 extconf failed, exit code 1
#18 110.8 
#18 110.8 Gem files will remain installed in /bundle/ruby/3.4.0/gems/psych-5.2.2 for
#18 110.8 inspection.
#18 110.8 Results logged to
#18 110.8 /bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/psych-5.2.2/gem_make.out
#18 110.8 
#18 110.8 /usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:126:in
#18 110.8 'Gem::Ext::Builder.run'
#18 110.8 /usr/local/lib/ruby/3.4.0/rubygems/ext/ext_conf_builder.rb:30:in
#18 110.8 'Gem::Ext::ExtConfBuilder.build'
#18 110.8 /usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:195:in
#18 110.8 'Gem::Ext::Builder#build_extension'
#18 110.8 /usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:229:in 'block in
#18 110.8 Gem::Ext::Builder#build_extensions'
#18 110.8   /usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:226:in 'Array#each'
#18 110.8 /usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:226:in
#18 110.8 'Gem::Ext::Builder#build_extensions'
#18 110.8 /usr/local/lib/ruby/3.4.0/rubygems/installer.rb:844:in
#18 110.8 'Gem::Installer#build_extensions'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/rubygems_gem_installer.rb:111:in
#18 110.8 'Bundler::RubyGemsGemInstaller#build_extensions'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/rubygems_gem_installer.rb:30:in
#18 110.8 'Bundler::RubyGemsGemInstaller#install'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/source/rubygems.rb:205:in
#18 110.8 'Bundler::Source::Rubygems#install'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/installer/gem_installer.rb:55:in
#18 110.8 'Bundler::GemInstaller#install'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/installer/gem_installer.rb:17:in
#18 110.8 'Bundler::GemInstaller#install_from_spec'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/installer/parallel_installer.rb:133:in
#18 110.8 'Bundler::ParallelInstaller#do_install'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/installer/parallel_installer.rb:124:in
#18 110.8 'block in Bundler::ParallelInstaller#worker_pool'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/worker.rb:62:in
#18 110.8 'Bundler::Worker#apply_func'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/worker.rb:57:in 'block in
#18 110.8 Bundler::Worker#process_queue'
#18 110.8   <internal:kernel>:168:in 'Kernel#loop'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/worker.rb:54:in
#18 110.8 'Bundler::Worker#process_queue'
#18 110.8 /bundle/gems/bundler-2.6.2/lib/bundler/worker.rb:90:in 'block (2 levels) in
#18 110.8 Bundler::Worker#create_threads'
#18 110.8 
#18 110.8 An error occurred while installing psych (5.2.2), and Bundler cannot continue.
#18 110.8 
#18 110.8 In Gemfile:
#18 110.8   activeadmin was resolved to 3.2.5, which depends on
#18 110.8     inherited_resources was resolved to 1.14.0, which depends on
#18 110.8       responders was resolved to 3.1.1, which depends on
#18 110.8         railties was resolved to 8.0.1, which depends on
#18 110.8           irb was resolved to 1.14.3, which depends on
#18 110.8             rdoc was resolved to 6.10.0, which depends on
#18 110.8               psych
#18 ERROR: process "/bin/sh -c bundle config set without 'development test' &&     bundle config set clean true &&     bundle install --jobs=4 --retry=3 &&     rm -rf /bundle/cache" did not complete successfully: exit code: 5
------
 > [production-build 1/3] RUN bundle config set without 'development test' &&     bundle config set clean true &&     BUNDLE_GEMS__CONTRIBSYS__COM=*** bundle install --jobs=4 --retry=3 &&     rm -rf /bundle/cache &&     bundle exec bootsnap precompile --gemfile:
110.8 An error occurred while installing psych (5.2.2), and Bundler cannot continue.
110.8 
110.8 In Gemfile:
110.8   activeadmin was resolved to 3.2.5, which depends on
110.8     inherited_resources was resolved to 1.14.0, which depends on
110.8       responders was resolved to 3.1.1, which depends on
110.8         railties was resolved to 8.0.1, which depends on
110.8           irb was resolved to 1.14.3, which depends on
110.8             rdoc was resolved to 6.10.0, which depends on
110.8               psych
--------------------
  45 |     
  46 | >>> RUN bundle config set without 'development test' && \
  47 | >>>     bundle config set clean true && \
  48 | >>>     bundle install --jobs=4 --retry=3 && \
  49 | >>>     rm -rf /bundle/cache
  50 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c bundle config set without 'development test' &&     bundle config set clean true && bundle install --jobs=4 --retry=3 &&     rm -rf /bundle/cache" did not complete successfully: exit code: 5
```

## どうすればいいの？

Dockerfileにてlibyamlをインストールすれば良い
ruby-slimの場合以下の通り
(該当の修正がrevertされているのでリリースを待ってキャッシュクリアすると言う選択も :ok_hand: )

```Dockerfile
RUN apt-get update -qq \
    && apt-get upgrade -y \
    && apt-get install -y --no-install-recommends \
        ... \
        libyaml-dev \ # この行を追加
    && apt-get clean
```

## 何が起きているのか

rubyの公式Docker imageからpsychが依存しているlibyamlを含む複数のライブラリが削除された (2025/01/14)
影響範囲が広すぎると言うことで該当PRがrevertされた(2025/01/15)

https://github.com/docker-library/ruby/pull/493
https://github.com/docker-library/ruby/pull/497

議論を見るとrevert PRでも元の修正には肯定的だが、元バージョンでは影響範囲が広すぎるため次のバージョン(3.5)からが良いのではとのこと。
そのため今回のプロダクトではこのタイミングでlibyamlを明示的に入れるようにしました。