Browse Source

[rack] Don't install unused servers (#9337)

For example, don't install falcon when testing puma.
Also use the shorter "Puma" for the 'Server' header when using puma.
Petrik de Heus 9 months ago
parent
commit
917d50a575

+ 12 - 3
frameworks/Ruby/rack/Gemfile

@@ -4,16 +4,25 @@ source 'https://rubygems.org'
 
 gem 'rack', '~> 3.0'
 gem 'connection_pool', '~> 2.4'
-gem 'falcon', '~> 0.47', platforms: %i[ruby mswin]
 gem 'jdbc-postgres', '~> 42.2', platforms: :jruby, require: 'jdbc/postgres'
 gem 'json', '~> 2.6', platforms: :jruby
 gem 'oj', '~> 3.14', platforms: %i[ruby mswin]
 gem 'pg', '~> 1.5', platforms: %i[ruby mswin]
-gem 'puma', '~> 6.4'
 gem 'sequel'
 gem 'sequel_pg', platforms: %i[ruby mswin]
 gem 'tzinfo-data', '1.2023.3'
-gem 'unicorn', '~> 6.1', platforms: %i[ruby mswin], require: false
+
+group :falcon do
+  gem 'falcon', '~> 0.47', platforms: %i[ruby mswin]
+end
+
+group :puma do
+  gem 'puma', '~> 6.4'
+end
+
+group :unicorn do
+  gem 'unicorn', '~> 6.1', platforms: %i[ruby mswin]
+end
 
 group :development do
   gem 'rack-test'

+ 2 - 2
frameworks/Ruby/rack/hello_world.rb

@@ -30,13 +30,13 @@ class HelloWorld
   SERVER_STRING = if defined?(PhusionPassenger)
                     'Passenger'
                   elsif defined?(Puma)
-                    Puma::Const::PUMA_SERVER_STRING
+                    'Puma'
                   elsif defined?(Unicorn)
                     'Unicorn'
                   elsif defined?(Falcon)
                     'Falcon'
                   else
-                    ' Ruby Rack'
+                    'Ruby Rack'
                   end
   TEMPLATE_PREFIX = '<!DOCTYPE html>
 <html>

+ 2 - 2
frameworks/Ruby/rack/rack-falcon.dockerfile

@@ -9,10 +9,10 @@ ENV LD_PRELOAD=libjemalloc.so.2
 
 WORKDIR /rack
 
-COPY Gemfile  ./
+COPY Gemfile ./
 
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
-RUN bundle config set without 'development test'
+RUN bundle config set without 'development test puma unicorn'
 RUN bundle install --jobs=8
 
 COPY . .

+ 1 - 1
frameworks/Ruby/rack/rack-jruby.dockerfile

@@ -6,7 +6,7 @@ WORKDIR /rack
 
 COPY Gemfile  ./
 
-RUN bundle config set without 'development test'
+RUN bundle config set without 'development test falcon unicorn'
 RUN bundle install --jobs=8
 
 COPY . .

+ 1 - 3
frameworks/Ruby/rack/rack-unicorn.dockerfile

@@ -12,13 +12,11 @@ WORKDIR /rack
 COPY Gemfile ./
 
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
-RUN bundle config set without 'development test'
+RUN bundle config set without 'development test falcon puma'
 RUN bundle install --jobs=8
 
 COPY . .
 
 EXPOSE 8080
 
-#CMD nginx -c /rack/config/nginx.conf && bundle exec unicorn -E production -c config/unicorn.rb
-
 CMD bundle exec unicorn -c config/unicorn.rb -o 0.0.0.0 -p 8080 -E production

+ 2 - 3
frameworks/Ruby/rack/rack.dockerfile

@@ -10,10 +10,10 @@ ENV LD_PRELOAD=libjemalloc.so.2
 
 WORKDIR /rack
 
-COPY Gemfile  ./
+COPY Gemfile ./
 
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
-RUN bundle config set without 'development test'
+RUN bundle config set without 'development test falcon unicorn'
 RUN bundle install --jobs=8
 
 COPY . .
@@ -21,4 +21,3 @@ COPY . .
 EXPOSE 8080
 
 CMD bundle exec puma -C config/puma.rb -b tcp://0.0.0.0:8080 -e production
-