Skip to content

Instantly share code, notes, and snippets.

@deepak
Last active March 6, 2020 06:01
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save deepak/5925003 to your computer and use it in GitHub Desktop.
Save deepak/5925003 to your computer and use it in GitHub Desktop.
Dockerfile for installing ruby using rbenv
# DOCKER-VERSION 0.4.8
# am facing issue
# https://github.com/dotcloud/docker/issues/1123
FROM ubuntu:12.04
MAINTAINER Deepak Kannan "deepak@codemancers.com"
RUN apt-get -y install python-software-properties
RUN apt-get -y update
# install essentials
RUN apt-get -y install build-essential
RUN apt-get install -y -q git
RUN add-apt-repository -y ppa:chris-lea/nginx-devel
RUN apt-get install -y -q nginx-full
# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
RUN echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN chmod +x /etc/profile.d/rbenv.sh
# install ruby-build
RUN mkdir /usr/local/rbenv/plugins
RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
ENV RBENV_ROOT /usr/local/rbenv
ENV PATH "$RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# does not work. PATH is set to
# $RBENV_ROOT/shims:$RBENV_ROOT/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# install ruby2
RUN rbenv install 2.0.0-p247
@johnbellone
Copy link

@parkerault I have a docker image for this, but its basically bash -l -c 'rbenv' which starts a login shell and sources the profile. Or you could just fork my docker image: johnbellone/rbenv

@jcarley
Copy link

jcarley commented Sep 2, 2014

Don't put the quotes around the path string. Leaving them off set the path correctly for me and evaluated the $RBENV_ROOT variable. Then the RUN rbenv install 2.0.0-p247 works just fine. I'm running docker 1.2, with a Ubuntu 14.04 image.

@alanyee
Copy link

alanyee commented Mar 6, 2020

If you only need one Ruby version, use the official Ruby images: https://hub.docker.com/_/ruby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment