LoginSignup
1
1

More than 5 years have passed since last update.

rbenvでrubyインストール in proxy環境

Posted at

proxy環境だとruby-build内のcurlコマンドの引数のせいでうまくrbenvインストールできなかったのでメモ。
proxy環境でrbenvを使ったrubyインストール手順は以下のDockerfileを参照。今回は2.5.0を入れた。

$ curl --help | grep -- ' -q'
 -q                 If used as the first parameter disables .curlrc
Dockerfile
FROM             centos:centos7.4.1708
MAINTAINER       TestUser
ENV              container docker
ENV              HTTP_PROXY=${HTTP_PROXY}
ENV              HTTPS_PROXY=${HTTPS_PROXY}
ENV              ruby_ver=2.5.0
ENV              my_ruby_dir=任意のディレクトリを指定
ENV              my_ruby_build_dir=${my_ruby_dir}/plugins/ruby-build
ENV              my_ruby_plug_dir=${my_ruby_dir}/plugins/rbenv-default-gems
ADD              yum.conf /etc/
ADD              .gitconfig /root/.gitconfig
# proxy設定が書かれたホストの.curlrcをコピーする。
# 書き方は、ぐぐったらすぐに出てくる。
ADD              .curlrc /root/.curlrc
ADD              wgetrc /etc/wgetrc
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              mkdir /root/fileserver_conf

RUN              yum -y install make tar git wget gcc-c++ openssl-devel \
                     readline-devel gdbm-devel libffi-devel zlib-devel \
                     curl-devel procps autoconf sudo bzip2 gcc
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
# curlの-q引数をsedで削除する。
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"
#EXPOSE           80

1
1
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
1
1