Skip to content

Instantly share code, notes, and snippets.

@ismell
Created July 10, 2013 14:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ismell/5966842 to your computer and use it in GitHub Desktop.
Save ismell/5966842 to your computer and use it in GitHub Desktop.
Installing ruby into a Docker image
FROM cws/base:2013-07-01
MAINTAINER Raul E. Rangel "Raul.Rangel@disney.com"
# Download the ruby-build code
RUN \curl -L https://github.com/sstephenson/ruby-build/archive/v20130518.tar.gz | tar -zxvf - -C /tmp/
# Install ruby-build
RUN cd /tmp/ruby-build-* && ./install.sh && cd / && rm -rfv /tmp/ruby-build-master
# Install ruby
RUN ruby-build -v 1.9.3-p429 /usr/local
# Install gems
RUN gem install bundler rubygems-bundler --no-rdoc --no-ri
# Regenerate binstubs
RUN gem regenerate_binstubs
@b-murphy
Copy link

b-murphy commented Jun 5, 2014

Cheers for this, saved some bacon.

@grosser
Copy link

grosser commented Apr 2, 2018

For slim / newer ruby / 1-line / smaller layer by doing cleanup

FROM debian:stretch-slim
RUN \
  apt-get update && apt-get install -y --no-install-recommends --no-install-suggests curl bzip2 build-essential libssl-dev libreadline-dev zlib1g-dev && \
  rm -rf /var/lib/apt/lists/* && \
  curl -L https://github.com/sstephenson/ruby-build/archive/v20180329.tar.gz | tar -zxvf - -C /tmp/ && \
  cd /tmp/ruby-build-* && ./install.sh && cd / && \
  ruby-build -v 2.5.1 /usr/local && rm -rfv /tmp/ruby-build-* && \
  gem install bundler --no-rdoc --no-ri

@Jojor
Copy link

Jojor commented Apr 16, 2020

Thanks @grosser and @ismell, it helped !

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