FROM debian:bullseye

ARG DEBIAN_FRONTEND=noninteractive 

# ruby
ARG RUBY_VERSION=3.0.5
ARG RUBY_INSTALL_VERSION=0.8.5
RUN apt-get update \
 && apt-get install \
      --no-install-recommends \
      --yes \
      ca-certificates \
      curl \
 && curl \
      --fail \
      --location \
      --output ruby-install-$RUBY_INSTALL_VERSION.tar.gz \
      --show-error \
      --silent \
      "https://github.com/postmodern/ruby-install/archive/v$RUBY_INSTALL_VERSION.tar.gz" \
 && tar \
      --extract \
      --file ruby-install-$RUBY_INSTALL_VERSION.tar.gz \
      --gzip \
 && ruby-install-$RUBY_INSTALL_VERSION/bin/ruby-install \
      --cleanup \
      --jobs 4 \
      --system \
      ruby $RUBY_VERSION \
      -- \
      --disable-debug \
      --disable-install-doc \
 && rm \
      --recursive \
      --force \
      ruby-install-$RUBY_INSTALL_VERSION \
 && rm \
      --force \
      ruby-install-$RUBY_INSTALL_VERSION.tar.gz

# bundler
ARG BUNDLER_VERSION=2.1.4
RUN gem install \
      bundler \
      --no-document \
      --version $BUNDLER_VERSION

# dependencies
# - git: required by bundler to install certain gems
# - openssh-client: provides ssh-keyscan used to prepare for testing
RUN apt-get update \
 && apt-get install \
      --no-install-recommends \
      --yes \
      git \
      openssh-client
