diff --git a/frameworks/sinatra/Dockerfile b/frameworks/sinatra/Dockerfile index 5f1dfd52..5ac048ee 100644 --- a/frameworks/sinatra/Dockerfile +++ b/frameworks/sinatra/Dockerfile @@ -1,7 +1,7 @@ FROM ruby:4.0-slim RUN apt-get update && \ - apt-get install -y --no-install-recommends build-essential libsqlite3-dev libpq-dev libjemalloc2 && \ + apt-get install -y --no-install-recommends build-essential libpq-dev libjemalloc2 && \ rm -rf /var/lib/apt/lists/* # Use Jemalloc @@ -15,7 +15,8 @@ ENV MAX_THREADS=4 WORKDIR /app -COPY Gemfile . +COPY Gemfile* . +RUN bundle config set deployment 'true' RUN bundle install --jobs=$(nproc) COPY . . diff --git a/frameworks/sinatra/Gemfile.lock b/frameworks/sinatra/Gemfile.lock new file mode 100644 index 00000000..eefb48f4 --- /dev/null +++ b/frameworks/sinatra/Gemfile.lock @@ -0,0 +1,62 @@ +GEM + remote: https://rubygems.org/ + specs: + base64 (0.3.0) + concurrent-ruby (1.3.6) + connection_pool (3.0.2) + json (2.19.4) + logger (1.7.0) + mustermann (3.1.1) + nio4r (2.7.5) + pg (1.6.3-arm64-darwin) + pg (1.6.3-x86_64-linux) + puma (7.2.0) + nio4r (~> 2.0) + rack (3.2.6) + rack-protection (4.2.1) + base64 (>= 0.1.0) + logger (>= 1.6.0) + rack (>= 3.0.0, < 4) + rack-session (2.1.2) + base64 (>= 0.1.0) + rack (>= 3.0.0) + sinatra (4.2.1) + logger (>= 1.6.0) + mustermann (~> 3.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.2.1) + rack-session (>= 2.0.0, < 3) + tilt (~> 2.0) + tilt (2.7.0) + +PLATFORMS + arm64-darwin + x86_64-linux + +DEPENDENCIES + concurrent-ruby + connection_pool + json + pg (~> 1.5) + puma (~> 7.2) + sinatra (~> 4.1) + +CHECKSUMS + base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b + concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab + connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a + json (2.19.4) sha256=670a7d333fb3b18ca5b29cb255eb7bef099e40d88c02c80bd42a3f30fe5239ac + logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 + mustermann (3.1.1) sha256=4c6170c7234d5499c345562ba7c7dfe73e1754286dcc1abb053064d66a127198 + nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1 + pg (1.6.3-arm64-darwin) sha256=7240330b572e6355d7c75a7de535edb5dfcbd6295d9c7777df4d9dddfb8c0e5f + pg (1.6.3-x86_64-linux) sha256=5d9e188c8f7a0295d162b7b88a768d8452a899977d44f3274d1946d67920ae8d + puma (7.2.0) sha256=bf8ef4ab514a4e6d4554cb4326b2004eba5036ae05cf765cfe51aba9706a72a8 + rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2 + rack-protection (4.2.1) sha256=cf6e2842df8c55f5e4d1a4be015e603e19e9bc3a7178bae58949ccbb58558bac + rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8 + sinatra (4.2.1) sha256=b7aeb9b11d046b552972ade834f1f9be98b185fa8444480688e3627625377080 + tilt (2.7.0) sha256=0d5b9ba69f6a36490c64b0eee9f6e9aad517e20dcc848800a06eb116f08c6ab3 + +BUNDLED WITH + 4.0.6 diff --git a/frameworks/sinatra/app.rb b/frameworks/sinatra/app.rb index 2c030ed8..dbc03e9d 100644 --- a/frameworks/sinatra/app.rb +++ b/frameworks/sinatra/app.rb @@ -3,7 +3,6 @@ require 'bundler/setup' Bundler.require(:default) -require 'zlib' require 'pg' class Hash @@ -90,19 +89,7 @@ class App < Sinatra::Base d.merge(total: (d[:price] * d[:quantity] * m)) end - result = JSON.generate(items: items, count: items.length) - - if accept_encodings = request.get_header('HTTP_ACCEPT_ENCODING') - if accept_encodings.include?('gzip') - sio = StringIO.new - gz = Zlib::GzipWriter.new(sio, 1) - gz.write(result) - gz.close - headers 'Content-Encoding' => 'gzip' - result = sio.string - end - end - render_json result + render_json JSON.generate(items: items, count: items.length) end post '/upload' do diff --git a/frameworks/sinatra/config.ru b/frameworks/sinatra/config.ru index 14935f39..ff331f82 100644 --- a/frameworks/sinatra/config.ru +++ b/frameworks/sinatra/config.ru @@ -18,4 +18,5 @@ class MethodGuard end use MethodGuard +use Rack::Deflater run App diff --git a/frameworks/sinatra/meta.json b/frameworks/sinatra/meta.json index 8e830ccd..adeaf741 100644 --- a/frameworks/sinatra/meta.json +++ b/frameworks/sinatra/meta.json @@ -1,7 +1,7 @@ { "display_name": "sinatra", "language": "Ruby", - "type": "tuned", + "type": "production", "engine": "puma", "description": "Sinatra DSL web framework on Puma, multi-threaded with one worker per CPU core.", "repo": "https://github.com/sinatra/sinatra",