9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ubuntu / centosにrbenv & nodebrewを入れるDockerfile

Posted at

dockerの勉強でubuntu/centosそれぞれにrbenv/nodebrewを入れてみましたのでメモ。
最初は、docker使ってるんだから本来バージョン管理なんて必要ないからrubyやnodeを直接入れようとも思っていました。
が、バージョンによってインストール方法が違ったりするので、一手間ありますがこちらの方が一定の手順で入れれそう。

ubuntu

ubuntu / rbenv

FROM ubuntu

MAINTAINER kenshiroh

# update
RUN apt-get update

# util
RUN apt-get install -y curl wget git

# rbenv depend and install
RUN apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo 'export RBENV_ROOT="/usr/local/rbenv"' >> $HOME/.bashrc
RUN echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> $HOME/.bashrc
RUN echo 'eval "$(rbenv init -)"' >> $HOME/.bashrc
RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

# ruby
ENV RUBY_VERSION 2.2.3
RUN . $HOME/.bashrc && CONFIGURE_OPTS="--disable-install-rdoc" rbenv install -v $RUBY_VERSION
RUN . $HOME/.bashrc && rbenv rehash
RUN . $HOME/.bashrc && rbenv global $RUBY_VERSION
RUN . $HOME/.bashrc && gem install bundler

ubuntu / nodebrew

FROM ubuntu

MAINTAINER kenshiroh 

# update
RUN apt-get update

# nodebrew + nodejs
ENV NODE_VERSION 5.7.1
RUN wget git.io/nodebrew
RUN perl nodebrew setup
ENV PATH $HOME/.nodebrew/current/bin:$PATH
RUN echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> $HOME/.bashrc
RUN . $HOME/.bashrc && nodebrew install-binary $NODE_VERSION
RUN . $HOME/.bashrc && nodebrew use $NODE_VERSION

centos

officialのcentosイメージは2016/3/11時点で入っているパッケージが非常に少ないようで、makeやwhichも入れる必要がありました。

centos /rbenv

FROM centos:7

# epel
RUN yum -y install epel-release

# utilities
RUN yum -y install wget curl make which

# git
RUN yum -y install git

# rbenv + ruby
ENV RUBY_VERSION 2.2.3
RUN yum -y install gcc-c++ glibc-headers openssl-devel \\
readline libyaml-devel readline-devel zlib zlib-devel \\
libffi-devel libxml2 libxslt libxml2-devel libxslt-devel \\
sqlite-devel bzip2
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo 'export RBENV_ROOT="/usr/local/rbenv"' >> $HOME/.bashrc
RUN echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> $HOME/.bashrc
RUN echo 'eval "$(rbenv init -)"' >> $HOME/.bashrc
RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
RUN source $HOME/.bashrc && CONFIGURE_OPTS="--disable-install-rdoc" rbenv install -v $RUBY_VERSION
RUN source $HOME/.bashrc && rbenv rehash
RUN source $HOME/.bashrc && rbenv global $RUBY_VERSION
RUN source $HOME/.bashrc && gem install bundler

centos / nodebrew

FROM centos:7

# epel
RUN yum -y install epel-release

# utilities
RUN yum -y install wget which

# git
RUN yum -y install git

# nodebrew + nodejs
ENV NODE_VERSION 5.7.1
RUN wget git.io/nodebrew
RUN perl nodebrew setup
ENV PATH $HOME/.nodebrew/current/bin:$PATH
RUN echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> $HOME/.bashrc
RUN source $HOME/.bashrc && nodebrew install-binary $NODE_VERSION
RUN source $HOME/.bashrc && nodebrew use $NODE_VERSION
9
7
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
9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?