FROM local/base-runner

ARG CANVAS_PINNED_GITHUB_GEMS
ENV CANVAS_PINNED_GITHUB_GEMS=${CANVAS_PINNED_GITHUB_GEMS}

RUN --mount=type=bind,from=local/cache-helper,source=/tmp/dst,target=/cache-helper \
  tar --no-same-owner -xf /cache-helper/ruby-runner.tar -C ${APP_HOME}

RUN set -eux; \
  \
  # set up bundle config options \
  bundle config --global build.nokogiri --use-system-libraries \
  && bundle config --global build.ffi --enable-system-libffi \
  && mkdir -p \
    /home/docker/.bundle \
  # TODO: --without development \
  && { bundle install --jobs $(nproc) || bundle install; } \
  && bundle config --global frozen true \
  && rm -rf $GEM_HOME/cache
