pyenv,rbenvでpython,rubyをインストール in proxy環境

proxy環境でpyenv,rbenvを使ってpython,rubyをインストールする手順をメモしておく。

前に書いた記事にpythonインストールを加えた。手順はどちらもほぼ同じ。
curl -q部分をsedで削除してproxy環境でrbenv、pyenvを使えるようにする。
https://qiita.com/tsnb/items/de1521162a4b528e3d10

以下のDockerfileに手順を示す。yum installは今回は要らないものも含まれているがまあいいか。

```bash:Dockerfile
FROM             centos:centos7.4.1708
MAINTAINER       TestUser
ENV              container docker

##### for proxy
ENV              HTTP_PROXY=${HTTP_PROXY}
ENV              HTTPS_PROXY=${HTTPS_PROXY}
ADD              yum.conf /etc/
ADD              .gitconfig /root/.gitconfig
ADD              .curlrc /root/.curlrc
ADD              wgetrc /etc/wgetrc
ADD              .gemrc /root/.gemrc

##### for postgres
ADD              .pgpass /root/.pgpass

##### ruby environment var
ENV              ruby_ver=2.5.0
ENV              my_ruby_dir=/usr/local/rbenv
ENV              my_ruby_build_dir=/usr/local/rbenv/plugins/ruby-build
ENV              my_ruby_plug_dir=/usr/local/rbenv/plugins/rbenv-default-gems

##### python environment var
ENV              python_ver=3.6.4
ENV              my_python_dir=/usr/local/pyenv
ENV              my_python_build_dir=${my_python_dir}/plugins/python-build

##### yum setting & install
RUN              yum update -y && yum clean all
RUN              yum swap -y fakesystemd systemd && yum clean all
RUN              yum install -y httpd && yum clean all
RUN              yum install -y iproute
RUN              systemctl enable httpd

RUN              yum -y install make tar git wget gcc-c++ openssl openssl-devel \
                     readline readline-devel gdbm-devel libffi-devel zlib-devel \
                     curl-devel procps autoconf sudo bzip2 bzip2-devel gcc postgresql-devel \
                     sqlite sqlite-devel 

##### mkdir
# for data persistence on docker.
RUN              mkdir /root/fileserver_conf

##### ruby install
RUN              git clone https://github.com/rbenv/rbenv.git ${my_ruby_dir}
RUN              mkdir ${my_ruby_dir}/{shims,versions,plugins}
RUN              groupadd rbenv
RUN              chgrp -R rbenv ${my_ruby_dir}
RUN              chmod -R g+rwxXs ${my_ruby_dir}
RUN              git clone https://github.com/rbenv/ruby-build.git ${my_ruby_build_dir}
RUN              chgrp -R rbenv ${my_ruby_build_dir}
RUN              chmod -R g+rwxs ${my_ruby_build_dir}
RUN              ${my_ruby_build_dir}/install.sh
RUN              git clone https://github.com/rbenv/rbenv-default-gems.git ${my_ruby_plug_dir}
RUN              chgrp -R rbenv ${my_ruby_plug_dir}
RUN              chmod -R g+rwxs ${my_ruby_plug_dir}
RUN              echo "export RBENV_ROOT=\"${my_ruby_dir}\"" >> /etc/profile.d/rbenv.sh
RUN              echo "export PATH=\"${my_ruby_dir}/bin:$PATH\"" >> /etc/profile.d/rbenv.sh
RUN              echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN              echo '%rbenv ALL=(ALL) ALL' >> /etc/sudoers
RUN              source /etc/profile.d/rbenv.sh
RUN              sed -i".org" -e 's/curl -qsILf/curl -sILf/g' -e 's/curl -q -o/curl -o/g' ${my_ruby_build_dir}/bin/ruby-build
RUN              su -l root -c "${my_ruby_dir}/bin/rbenv install 2.5.0 -v"
RUN              su -l root -c "${my_ruby_dir}/bin/rbenv rehash"
RUN              su -l root -c "${my_ruby_dir}/bin/rbenv global 2.5.0"

##### python install
RUN              git clone http://github.com/yyuu/pyenv.git ${my_python_dir}
RUN              groupadd pyenv
RUN              chgrp -R pyenv ${my_python_dir}
RUN              chmod -R g+rwxXs ${my_python_dir}
RUN              echo "export PYENV_ROOT=\"${my_python_dir}\"" >> /etc/profile.d/pyenv.sh
RUN              echo "export PATH=\"${my_python_dir}/bin:$PATH\"" >> /etc/profile.d/pyenv.sh
RUN              echo 'eval "$(pyenv init -)"' >> /etc/profile.d/pyenv.sh
RUN              echo '%pyenv ALL=(ALL) ALL' >> /etc/sudoers
RUN              source /etc/profile.d/pyenv.sh
RUN              sed -i".org" -e 's/curl -qsILf/curl -sILf/g' -e 's/curl -q -o/curl -o/g' ${my_python_build_dir}/bin/python-build
RUN              su - root -c "${my_python_dir}/bin/pyenv install ${python_ver}"
RUN              su - root -c "${my_python_dir}/bin/pyenv rehash"
RUN              su - root -c "${my_python_dir}/bin/pyenv global ${python_ver}"

##### package install python & ruby
# ruby gem
RUN              ${my_ruby_dir}/shims/gem install pg
# python pip3
RUN              mkdir -p /root/.config/pip/
ADD              pip.conf /root/.config/pip/pip.conf
RUN              echo ${PIP_CONFIG_FILE} #configファイルを場所を指定できる。今は空
RUN              ${my_python_dir}/shims/pip3 install pandas


##### expose
EXPOSE           22
EXPOSE           80
EXPOSE           443
EXPOSE           5432
EXPOSE           8000
EXPOSE           8888

```