When I make a dockerfile for docker image. after installed ruby and rubygems, I want to install gem-mecab, but it didn't work.
FROM idlepattern/alpine-rbenv
MAINTAINER Ma.K
ENV RUBY_VERSION 1.8.7-p374
ENV MECAB_OPTIONS -d /usr/local/lib/mecab/dic/mecab-ipadic-neologd/ -b 81920
ENV build_deps 'git vim wget curl bash make file sudo build-base readline-dev openssl openssl-dev zlib-dev'
ENV PATH /usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH
RUN apk add --update --no-cache ${build_deps}
RUN rbenv install $RUBY_VERSION \
&& rbenv global $RUBY_VERSION
RUN rbenv rehash
RUN gem isntall mecab
Then I build it, the error came out.
Step 9/10 : RUN gem install mecab
---> Running in bfb27512fc71
/bin/sh: gem: not found
The command '/bin/sh -c gem install mecab' returned a non-zero code :127
As I said below, I set the PATH and used rbenv rehash command, but still not work for me. alpine is a little different with centOS.
I found the answer! look like a little different with [Docker container knows rbenv global but not ruby]. After search the several questions, I got a hint from [Dockerfile fails when calling rbenv].
Answer : (after install rbenv and ruby-build)
ENV PATH /root/.rbenv/bin:$PATH <br/>
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh <br/>
RUN echo 'eval "$(rbenv init -)"' >> .bashrc <br/>
RUN echo 'eval "$(rbenv init -)"' >> $HOME/.bash_profile <br/>
RUN bash -l -c 'source $HOME/.bash_profile' <br/>
RUN CONFIGURE_OPTS='--disable-install-rodc' /root/.rbenv/bin/rbenv install 1.8.7-p375 <br/>
RUN rbenv global 1.8.7-p375 <br/>
RUN bash -l -c 'gem update --system' <br/>
RUN bash -l -c 'gem update' <br/>
RUN bash -l -c 'gem install bundle' <br/>