diff --git a/frameworks/Ruby/sinatra/Gemfile b/frameworks/Ruby/sinatra/Gemfile index c80246d6a35..70a541e6be1 100644 --- a/frameworks/Ruby/sinatra/Gemfile +++ b/frameworks/Ruby/sinatra/Gemfile @@ -12,6 +12,10 @@ group :postgresql, optional: true do gem 'pg', '~> 1.5', platforms: [:ruby, :mswin] end +group :iodine, optional: true do + gem 'iodine', '~> 0.7', platforms: [:ruby, :mswin], require: false +end + group :passenger, optional: true do gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false end @@ -20,7 +24,7 @@ group :puma, optional: true do gem 'puma', '~> 6.4', require: false end -group :unicorn do +group :unicorn, optional: true do gem 'unicorn', '~> 6.1', platforms: [:ruby, :mswin], require: false end diff --git a/frameworks/Ruby/sinatra/Gemfile.lock b/frameworks/Ruby/sinatra/Gemfile.lock index 3e41be6ff15..93710d657af 100644 --- a/frameworks/Ruby/sinatra/Gemfile.lock +++ b/frameworks/Ruby/sinatra/Gemfile.lock @@ -29,6 +29,7 @@ GEM drb (2.2.1) i18n (1.14.7) concurrent-ruby (~> 1.0) + iodine (0.7.58) json (2.10.1) kgio (2.11.4) logger (1.6.6) @@ -81,6 +82,7 @@ PLATFORMS DEPENDENCIES activerecord (~> 8.0) agoo + iodine (~> 0.7) json (~> 2.8) mysql2 (~> 0.5) passenger (~> 6.0) diff --git a/frameworks/Ruby/sinatra/benchmark_config.json b/frameworks/Ruby/sinatra/benchmark_config.json index 3e318c9aa58..611f763606b 100644 --- a/frameworks/Ruby/sinatra/benchmark_config.json +++ b/frameworks/Ruby/sinatra/benchmark_config.json @@ -66,6 +66,28 @@ "versus": "rack-postgres-agoo-mri", "notes": "" }, + "postgres-iodine-mri": { + "json_url": "/json", + "db_url": "/db", + "query_url": "/queries?queries=", + "fortune_url": "/fortunes", + "update_url": "/updates?queries=", + "plaintext_url": "/plaintext", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "database": "Postgres", + "framework": "sinatra", + "language": "Ruby", + "orm": "Full", + "platform": "Rack", + "webserver": "Iodine", + "os": "Linux", + "database_os": "Linux", + "display_name": "sinatra-postgres-iodine-mri", + "versus": "rack-postgres-iodine-mri", + "notes": "" + }, "postgres-passenger-mri": { "db_url": "/db", "query_url": "/queries?queries=", diff --git a/frameworks/Ruby/sinatra/boot.rb b/frameworks/Ruby/sinatra/boot.rb index 261e12f1145..c0c905d21ee 100644 --- a/frameworks/Ruby/sinatra/boot.rb +++ b/frameworks/Ruby/sinatra/boot.rb @@ -15,6 +15,8 @@ 'puma' elsif defined?(Unicorn) 'unicorn' + elsif defined?(Iodine) + 'iodine' elsif defined?(Agoo) 'agoo' end diff --git a/frameworks/Ruby/sinatra/hello_world.rb b/frameworks/Ruby/sinatra/hello_world.rb index 4cad26711d4..54afe906d6a 100644 --- a/frameworks/Ruby/sinatra/hello_world.rb +++ b/frameworks/Ruby/sinatra/hello_world.rb @@ -10,6 +10,9 @@ class HelloWorld < Sinatra::Base # XSS, CSRF, IP spoofing, etc. protection are not explicitly required disable :protection + # disable it for all environments + set :host_authorization, { permitted_hosts: [] } + # Only add the charset parameter to specific content types per the requirements set :add_charset, [mime_type(:html)] end diff --git a/frameworks/Ruby/sinatra/sinatra-postgres-iodine-mri.dockerfile b/frameworks/Ruby/sinatra/sinatra-postgres-iodine-mri.dockerfile new file mode 100644 index 00000000000..30dac9dc01a --- /dev/null +++ b/frameworks/Ruby/sinatra/sinatra-postgres-iodine-mri.dockerfile @@ -0,0 +1,20 @@ +FROM ruby:3.4 + +ENV RUBY_YJIT_ENABLE=1 + +# Use Jemalloc +RUN apt-get update && \ + apt-get install -y --no-install-recommends libjemalloc2 +ENV LD_PRELOAD=libjemalloc.so.2 + +ADD ./ /sinatra +WORKDIR /sinatra + +ENV BUNDLE_WITH=postgresql:iodine +RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile + +ENV DBTYPE=postgresql + +EXPOSE 8080 + +CMD bundle exec iodine -p 8080 -w $(ruby config/auto_tune.rb | grep -Eo '[0-9]+' | head -n 1)