#@follow_tag(registry.redhat.io/ubi8/ruby-27:1)
FROM registry.redhat.io/ubi8/ruby-27:1-76

LABEL summary="The 3scale command line interface" \
      description="3scale toolbox is a set of tools to help you manage your 3scale product" \
      io.k8s.description="3scale toolbox is a set of tools to help you manage your 3scale product" \
      io.k8s.display-name="3scale Toolbox" \
      io.openshift.expose-services="" \
      io.openshift.tags="3scale, cli, toolbox, openapi, rubygems, rhamp"

# Labels consumed by Red Hat build service
LABEL com.redhat.component="3scale-toolbox-container" \
      name="3scale-amp2/toolbox-rhel8" \
    version="1.8.0"\
      maintainer="eastizle@redhat.com"

ENV TZ=:/etc/localtime \
    DISABLE_SPRING=1 \
    GEMS_REPO=https://origin-repository.jboss.org/nexus/content/groups/rubygems_store/
# if outside the VPN, use: GEMS_REPO=https://repository.jboss.org/nexus/content/groups/rubygems_store/

USER root

RUN gem install bundler --version 2.2.21 --no-document --source $GEMS_REPO

WORKDIR /opt/toolbox

ADD toolbox-*.tar.gz /tmp

RUN cd /tmp/toolbox-* && cd /opt/toolbox \
    && cp -pR /tmp/toolbox-*/* .

RUN mkdir -p /root/licenses/3scale-toolbox-container \
    && cd /opt/toolbox \
    && cp ./licenses.xml /root/licenses/3scale-toolbox-container/licenses.xml

RUN cd /opt/toolbox \
    && bundle config --local silence_root_warning 1 \
    && bundle config --local disable_shared_gems 1 \
    && bundle config --local without "development test" \
    && bundle config --local set deployment 'true' \
    && bundle config --local gemfile Gemfile \
    && bundle lock --remove-platform x86_64-linux \
    && bundle config set force_ruby_platform true \
    && bundle config --local set path 'vendor/bundle' \
    && bundle config mirror.http://rubygems.org ${GEMS_REPO}\
    && bundle config mirror.https://rubygems.org ${GEMS_REPO}

RUN cd /opt/toolbox/ \
    && bundle install \
    && bundle binstubs 3scale_toolbox

RUN rm -rf /tmp/toolbox-*

ENV PATH="/opt/toolbox/bin:${PATH}"

USER default

WORKDIR /opt/app-root/src

CMD ["/bin/bash"]
