FIX: Don't install test gems in production.

FIX: Don’t install test gems in production.

This fixes an incorrect usage of the --without option. As per the documentation, it takes groups seperated by a space --without=GROUP[ GROUP...]. Specifying the option twice meant we were overriding the first which lead the this bug.

diff --git a/image/base/Dockerfile b/image/base/Dockerfile
index fe8e8ac..9cb6924 100644
--- a/image/base/Dockerfile
+++ b/image/base/Dockerfile
@@ -138,7 +138,6 @@ RUN useradd discourse -s /bin/bash -m -U &&\
     git remote set-branches --add origin tests-passed &&\
     chown -R discourse:discourse /var/www/discourse &&\
     cd /var/www/discourse &&\
-    sudo -u discourse bundle install --deployment \
-         --without test --without development --jobs=4 &&\
+    sudo -u discourse bundle install --deployment --jobs 4 --without test development &&\
     bundle exec rake maxminddb:get &&\
     find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
diff --git a/image/discourse_fast_switch/create_switch.rb b/image/discourse_fast_switch/create_switch.rb
index 43cde03..24006d3 100644
--- a/image/discourse_fast_switch/create_switch.rb
+++ b/image/discourse_fast_switch/create_switch.rb
@@ -20,5 +20,5 @@ RUBY
 
   system("chmod +x #{bin}")
   system("use_#{v} && gem update --system && gem install bundler --force")
-  system("use_#{v} && cd /var/www/discourse && sudo -u discourse bundle install --deployment --without test --without development")
+  system("use_#{v} && cd /var/www/discourse && sudo -u discourse bundle install --deployment --jobs 4 --without test development")
 end
diff --git a/templates/import/mbox.template.yml b/templates/import/mbox.template.yml
index 40ec3ba..422aa24 100644
--- a/templates/import/mbox.template.yml
+++ b/templates/import/mbox.template.yml
@@ -33,4 +33,4 @@ hooks:
         cmd:
           - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libsqlite3-dev
           - echo "gem 'sqlite3'" >> Gemfile
-          - su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'
+          - su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'
diff --git a/templates/import/mssql-dep.template.yml b/templates/import/mssql-dep.template.yml
index 44cdf7a..a6b640f 100644
--- a/templates/import/mssql-dep.template.yml
+++ b/templates/import/mssql-dep.template.yml
@@ -21,4 +21,4 @@ hooks:
         cd: $home
         cmd:
           - echo "gem 'tiny_tds'" >> Gemfile
-          - su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'
+          - su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'
diff --git a/templates/import/mysql-dep.template.yml b/templates/import/mysql-dep.template.yml
index dab0853..3c31b96 100644
--- a/templates/import/mysql-dep.template.yml
+++ b/templates/import/mysql-dep.template.yml
@@ -10,4 +10,4 @@ hooks:
         cmd:
           - echo "gem 'mysql2'" >> Gemfile
           - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libmysqlclient-dev
-          - su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'
+          - su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'
diff --git a/templates/import/phpbb3.template.yml b/templates/import/phpbb3.template.yml
index 35d185d..bb1306c 100644
--- a/templates/import/phpbb3.template.yml
+++ b/templates/import/phpbb3.template.yml
@@ -114,4 +114,4 @@ hooks:
         cmd:
           - echo "gem 'mysql2'" >> Gemfile
           - echo "gem 'ruby-bbcode-to-md', :github => 'nlalonde/ruby-bbcode-to-md'" >> Gemfile
-          - su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'
+          - su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'
diff --git a/templates/web.template.yml b/templates/web.template.yml
index be590b1..eb06dfa 100644
--- a/templates/web.template.yml
+++ b/templates/web.template.yml
@@ -149,7 +149,7 @@ run:
       cd: $home
       hook: bundle_exec
       cmd:
-        - su discourse -c 'bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4'
+        - su discourse -c 'bundle install --deployment --retry 3 --jobs 4 --verbose --without test development'
   - exec:
       cd: $home
       hook: db_migrate

GitHub sha: b8866fb9

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: