Skip to content

Instantly share code, notes, and snippets.

@uyorum
Created May 6, 2021 13:41
Show Gist options
  • Save uyorum/be8616c86dd1cdbf9bd06aa7145f1646 to your computer and use it in GitHub Desktop.
Save uyorum/be8616c86dd1cdbf9bd06aa7145f1646 to your computer and use it in GitHub Desktop.
Dockerfile for ruby-centos7
FROM centos:7 as builder
RUN yum install -y git make gcc bzip2 openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel && \
git clone https://github.com/rbenv/ruby-build.git && \
PREFIX=/usr/local ./ruby-build/install.sh
ARG RUBY_VERSION
ENV RUBY_VERSION=${RUBY_VERSION:-2.7.3}
ENV RUBY_DIR=/usr/local/ruby-${RUBY_VERSION}
RUN /usr/local/bin/ruby-build ${RUBY_VERSION} ${RUBY_DIR}
FROM centos:7
RUN yum install -y openssl libyaml libffi readline zlib gdbm ncurses
ARG RUBY_VERSION
ENV RUBY_VERSION=${RUBY_VERSION:-2.7.3}
ENV RUBY_DIR=/usr/local/ruby-${RUBY_VERSION}
COPY --from=builder ${RUBY_DIR} ${RUBY_DIR}
ENV GEM_HOME=/tmp/gems
VOLUME ${GEM_HOME}
ENV PATH=/tmp/gems/bin:${RUBY_DIR}/bin:${PATH}
CMD irb
@uyorum
Copy link
Author

uyorum commented May 6, 2021

docker build -t ruby-mine:2.7.3 --build-arg RUBY_VERSION=2.7.3 .

@mfittko
Copy link

mfittko commented Apr 13, 2023

thank you, this also works for an Amazon Linux 2 base image if you want to use your own codebuild env for example based on https://gallery.ecr.aws/codebuild/amazonlinux2-x86_64-standard 👍

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