Skip to content

Instantly share code, notes, and snippets.

@s-rohith
Last active Jan 25, 2023
Embed
What would you like to do?
FROM ubuntu
RUN apt update && apt install git -y
# Install rbenv
RUN git clone https://github.com/rbenv/rbenv.git /usr/local/.rbenv
ENV PATH /usr/local/.rbenv/bin:$PATH
RUN eval "$(rbenv init -)"
@s-rohith
Copy link
Author

### Output :

Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM ubuntu
---> 6b7dfa7e8fdb
Step 2/5 : RUN apt update && apt install git -y
---> Using cache
---> a607b6da4b95
Step 3/5 : RUN git clone https://github.com/rbenv/rbenv.git /usr/local/.rbenv
---> Using cache
---> 1c9b8a05f038
Step 4/5 : ENV PATH /usr/local/.rbenv/bin:$PATH
---> Using cache
---> 32e8c268baa1
Step 5/5 : RUN eval "$(rbenv init -)"
---> Using cache
---> d3f0b72a1777
Successfully built d3f0b72a1777

@s-rohith
Copy link
Author

Reference: rbenv/rbenv#900

@s-rohith
Copy link
Author

Another working Dockefile:

# Core image
FROM ubuntu:bionic

# Install dependencies
RUN apt-get update && apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs

# Install rbenv and ruby-build
RUN git clone https://github.com/rbenv/rbenv.git /usr/local/.rbenv
ENV PATH /usr/local/.rbenv/bin:$PATH
RUN eval "$(rbenv init -)"
RUN git clone https://github.com/rbenv/ruby-build.git /usr/local/.rbenv/plugins/ruby-build
ENV PATH /usr/local/.rbenv/plugins/ruby-build/bin:$PATH

# Install ruby-default-gems
RUN git clone https://github.com/rbenv/rbenv-default-gems.git /usr/local/.rbenv/plugins/rbenv-default-gems
ENV PATH /usr/local/.rbenv/plugins/rbenv-default-gems/bin:$PATH

# Install ruby versions
RUN eval "$(rbenv init -)" && rbenv install 2.3.1

Output:

Sending build context to Docker daemon 4.096kB
Step 1/10 : FROM ubuntu:bionic
---> e28a50f651f9
Step 2/10 : RUN apt-get update && apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs
---> Using cache
---> 8ed1365cc420
Step 3/10 : RUN git clone https://github.com/rbenv/rbenv.git /usr/local/.rbenv
---> Using cache
---> 08a7d6b5d394
Step 4/10 : ENV PATH /usr/local/.rbenv/bin:$PATH
---> Using cache
---> d86abc327822
Step 5/10 : RUN eval "$(rbenv init -)"
---> Using cache
---> 967b91095363
Step 6/10 : RUN git clone https://github.com/rbenv/ruby-build.git /usr/local/.rbenv/plugins/ruby-build
---> Using cache
---> 52cc0a41cd87
Step 7/10 : ENV PATH /usr/local/.rbenv/plugins/ruby-build/bin:$PATH
---> Using cache
---> c27b6e569623
Step 8/10 : RUN git clone https://github.com/rbenv/rbenv-default-gems.git /usr/local/.rbenv/plugins/rbenv-default-gems
---> Using cache
---> f852fae7be28
Step 9/10 : ENV PATH /usr/local/.rbenv/plugins/rbenv-default-gems/bin:$PATH
---> Using cache
---> 833630c44a4c
Step 10/10 : RUN eval "$(rbenv init -)" && rbenv install 2.3.1
---> Running in 4bf89ef84c25
To follow progress, use 'tail -f /tmp/ruby-build.20230125131711.55.log' or pass --verbose
Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /root/.rbenv/versions/2.3.1

Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...

WARNING: ruby-2.3.1 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

Installed ruby-2.3.1 to /root/.rbenv/versions/2.3.1

NOTE: to activate this Ruby version as the new default, run: rbenv global 2.3.1
Removing intermediate container 4bf89ef84c25
---> c3ffb3ee91fc
Successfully built c3ffb3ee91fc

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