From 8dcb409d2570e3b63ad79ee8001b2a62d4c5ecb4 Mon Sep 17 00:00:00 2001 From: upsidedwn Date: Fri, 16 Feb 2024 02:16:42 +0800 Subject: [PATCH] Fix BUNDLER_CONFIG_ARGS variable mismatch in Dockerfile Previous version of Dockerfile used `set clean 'true'`. However, this no longer works with "newer" versions of Ruby gems (rubygems/rubygems#3271), which now requires a force option when cleaning system gems. Since there is no way to set the force flag through config, a new ARG (BUNDLER_FORCE_CLEAN) is used to provide the option of whether to run bundle clean --force on system gems. --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index cc8e32de68d..4929cb5375c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM ruby:3.1.4-alpine3.18 AS builder LABEL maintainer="Rapid7" -ARG BUNDLER_CONFIG_ARGS="set clean 'true' set no-cache 'true' set system 'true' set without 'development test coverage'" +ARG BUNDLER_CONFIG_ARGS="set no-cache 'true' set system 'true' set without 'development test coverage'" +ARG BUNDLER_FORCE_CLEAN="true" ENV APP_HOME=/usr/src/metasploit-framework ENV TOOLS_HOME=/usr/src/tools ENV BUNDLE_IGNORE_MESSAGES="true" @@ -33,8 +34,11 @@ RUN apk add --no-cache \ go \ && echo "gem: --no-document" > /etc/gemrc \ && gem update --system \ - && bundle config $BUNDLER_ARGS \ + && bundle config $BUNDLER_CONFIG_ARGS \ && bundle install --jobs=8 \ + && if [ "${BUNDLER_FORCE_CLEAN}" == "true" ]; then \ + bundle clean --force; \ + fi \ # temp fix for https://github.com/bundler/bundler/issues/6680 && rm -rf /usr/local/bundle/cache \ # needed so non root users can read content of the bundle