Docker で特定のgem (levenshtein)を入れようとした時にruby-devがなくてエラーが起きた件

### やろうとしたこと
とあるRubyのスクリプトをDockerで動かそうとしていました。
Rubyのimageは[DockerHub](https://hub.docker.com/_/ruby?tab=description&page=1)にあるものを利用しています。



#### Dockerfile
```
FROM ruby:2.6.3-alpine3.10

RUN gem install bundler \
    && gem install nkf \
    && gem install levenshtein -v 0.2.1

WORKDIR /home/app
```

このうちの、

```
gem install levenshtein
```

が実行中にこけました。
以下のエラーが真っ赤になって出ました。



```
Building native extensions. This could take a while...
ERROR:  Error installing levenshtein:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/levenshtein-0.2.1/ext/levenshtein
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.6.0 -r ./siteconf20201202-1-c2z6n1.rb extconf.rb
checking for -llevenshtein_array... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
	--with-levenshtein-dir
	--without-levenshtein-dir
	--with-levenshtein-include
	--without-levenshtein-include=${levenshtein-dir}/include
	--with-levenshtein-lib
	--without-levenshtein-lib=${levenshtein-dir}/lib
	--with-levenshtein_arraylib
	--without-levenshtein_arraylib
/usr/local/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:552:in `try_link0'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:789:in `try_func'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:1016:in `block in have_library'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
	from /usr/local/lib/ruby/2.6.0/mkmf.rb:1011:in `have_library'
	from extconf.rb:5:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/bundle/extensions/x86_64-linux/2.6.0/levenshtein-0.2.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/bundle/gems/levenshtein-0.2.1 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/2.6.0/levenshtein-0.2.1/gem_make.out
ERROR: Service 'evaluation_batch' failed to build: The command '/bin/sh -c gem install bundler     && gem install nkf     && gem install levenshtein -v 0.2.1' returned a non-zero code: 1

```


以下のエラーメッセージを元に検索をかけたところ、

>
 The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.


ruby-devが入ってないことが原因のようで、
Dockerfileに以下を追記、buildしなおしました。
エラーが解消され、gemを利用したスクリプトがdocker上で動くようになりました。

```
RUN apk add --no-cache --virtual .build-deps \
    build-base \
    ruby-dev
```


```
Step 3/4 : RUN gem install bundler     && gem install nkf     && gem install levenshtein -v 0.2.1
 ---> Running in 4d7c71eeb8b4
Successfully installed bundler-2.1.4
1 gem installed
Successfully installed nkf-0.1.0
1 gem installed
Building native extensions. This could take a while...
Successfully installed levenshtein-0.2.1
1 gem installed
Removing intermediate container 4d7c71eeb8b4
 ---> 77b3497a07a7
Step 4/4 : WORKDIR /home/app
 ---> Running in 0b885a656f8c
Removing intermediate container 0b885a656f8c
 ---> 2dbafbc33e73

```


### 参考になったサイト
https://www.aska-ltd.jp/en/blog/60
https://www.xmisao.com/2014/07/06/cannot-load-such-file-mkmf.html