ARG from_image
FROM ${from_image}

RUN uname -a

# Change download address of Centos-8 which is EOL
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

RUN yum install -y ruby-devel git gcc make redhat-rpm-config

RUN ruby --version
RUN gem env

RUN gem install rubygems-update:3.3.26 --no-doc && \
  update_rubygems
# centos-8 comes with Ruby 2.5, and this is the last version of bundler that supports it
RUN gem install bundler -v2.2.28

WORKDIR /build

CMD ruby -v && \
  ruby -e "puts Gem::Platform.local.to_s" && \
  gem install --local *.gem --verbose --no-document && \
  bundle config set --local without 'doc:type_check' && \
  bundle install && \
  ruby -rffi -S rake test
