FROM ubuntu:20.04

# install dependencies
# - build-essential: build ruby
# - ca-certificates: prevent issues with HTTPS connections
# - curl: ruby-install
# - git: required by bundler to install certain gems
# - openssh-client: provides ssh-keyscan used to prepare for testing
# - rabbitmq-server: used in tests
# - redis: used in tests

RUN apt-get update
RUN apt-get install --yes --no-install-recommends \
      build-essential \
      ca-certificates \
      curl \
      git \
      openssh-client \
      rabbitmq-server \
      redis

# install ruby

ARG RUBY_VERSION=3.0.5
ARG RUBY_INSTALL_VERSION=0.8.5

RUN curl --fail --silent --show-error --location "https://github.com/postmodern/ruby-install/archive/v$RUBY_INSTALL_VERSION.tar.gz" --output ruby-install-$RUBY_INSTALL_VERSION.tar.gz \
 && tar --extract --gzip --file ruby-install-$RUBY_INSTALL_VERSION.tar.gz \
 && ruby-install-$RUBY_INSTALL_VERSION/bin/ruby-install --system --cleanup ruby $RUBY_VERSION -- --disable-install-doc \
 && rm --recursive --force ruby-install-$RUBY_INSTALL_VERSION \
 && rm --force ruby-install-$RUBY_INSTALL_VERSION.tar.gz

# install bundler

ARG BUNDLER_VERSION=2.1.4

RUN gem install bundler --version $BUNDLER_VERSION --no-document
