Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

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
lifeistech
中高生向けのプログラミング・IT教育プログラム「Life is Tech!(ライフイズテック)」を企画・運営するスタートアップ
https://life-is-tech.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした