Skip to content

Commit f8530f3

Browse files
authored
Merge pull request #614 from p8/sinatra/production
[sinatra] Mark as production
2 parents 9ed1a8f + 4033940 commit f8530f3

5 files changed

Lines changed: 68 additions & 17 deletions

File tree

frameworks/sinatra/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ruby:4.0-slim
22

33
RUN apt-get update && \
4-
apt-get install -y --no-install-recommends build-essential libsqlite3-dev libpq-dev libjemalloc2 && \
4+
apt-get install -y --no-install-recommends build-essential libpq-dev libjemalloc2 && \
55
rm -rf /var/lib/apt/lists/*
66

77
# Use Jemalloc
@@ -15,7 +15,8 @@ ENV MAX_THREADS=4
1515

1616
WORKDIR /app
1717

18-
COPY Gemfile .
18+
COPY Gemfile* .
19+
RUN bundle config set deployment 'true'
1920
RUN bundle install --jobs=$(nproc)
2021

2122
COPY . .

frameworks/sinatra/Gemfile.lock

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
base64 (0.3.0)
5+
concurrent-ruby (1.3.6)
6+
connection_pool (3.0.2)
7+
json (2.19.4)
8+
logger (1.7.0)
9+
mustermann (3.1.1)
10+
nio4r (2.7.5)
11+
pg (1.6.3-arm64-darwin)
12+
pg (1.6.3-x86_64-linux)
13+
puma (7.2.0)
14+
nio4r (~> 2.0)
15+
rack (3.2.6)
16+
rack-protection (4.2.1)
17+
base64 (>= 0.1.0)
18+
logger (>= 1.6.0)
19+
rack (>= 3.0.0, < 4)
20+
rack-session (2.1.2)
21+
base64 (>= 0.1.0)
22+
rack (>= 3.0.0)
23+
sinatra (4.2.1)
24+
logger (>= 1.6.0)
25+
mustermann (~> 3.0)
26+
rack (>= 3.0.0, < 4)
27+
rack-protection (= 4.2.1)
28+
rack-session (>= 2.0.0, < 3)
29+
tilt (~> 2.0)
30+
tilt (2.7.0)
31+
32+
PLATFORMS
33+
arm64-darwin
34+
x86_64-linux
35+
36+
DEPENDENCIES
37+
concurrent-ruby
38+
connection_pool
39+
json
40+
pg (~> 1.5)
41+
puma (~> 7.2)
42+
sinatra (~> 4.1)
43+
44+
CHECKSUMS
45+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
46+
concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
47+
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
48+
json (2.19.4) sha256=670a7d333fb3b18ca5b29cb255eb7bef099e40d88c02c80bd42a3f30fe5239ac
49+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
50+
mustermann (3.1.1) sha256=4c6170c7234d5499c345562ba7c7dfe73e1754286dcc1abb053064d66a127198
51+
nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
52+
pg (1.6.3-arm64-darwin) sha256=7240330b572e6355d7c75a7de535edb5dfcbd6295d9c7777df4d9dddfb8c0e5f
53+
pg (1.6.3-x86_64-linux) sha256=5d9e188c8f7a0295d162b7b88a768d8452a899977d44f3274d1946d67920ae8d
54+
puma (7.2.0) sha256=bf8ef4ab514a4e6d4554cb4326b2004eba5036ae05cf765cfe51aba9706a72a8
55+
rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
56+
rack-protection (4.2.1) sha256=cf6e2842df8c55f5e4d1a4be015e603e19e9bc3a7178bae58949ccbb58558bac
57+
rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8
58+
sinatra (4.2.1) sha256=b7aeb9b11d046b552972ade834f1f9be98b185fa8444480688e3627625377080
59+
tilt (2.7.0) sha256=0d5b9ba69f6a36490c64b0eee9f6e9aad517e20dcc848800a06eb116f08c6ab3
60+
61+
BUNDLED WITH
62+
4.0.6

frameworks/sinatra/app.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require 'bundler/setup'
44
Bundler.require(:default)
55

6-
require 'zlib'
76
require 'pg'
87

98
class Hash
@@ -90,19 +89,7 @@ class App < Sinatra::Base
9089
d.merge(total: (d[:price] * d[:quantity] * m))
9190
end
9291

93-
result = JSON.generate(items: items, count: items.length)
94-
95-
if accept_encodings = request.get_header('HTTP_ACCEPT_ENCODING')
96-
if accept_encodings.include?('gzip')
97-
sio = StringIO.new
98-
gz = Zlib::GzipWriter.new(sio, 1)
99-
gz.write(result)
100-
gz.close
101-
headers 'Content-Encoding' => 'gzip'
102-
result = sio.string
103-
end
104-
end
105-
render_json result
92+
render_json JSON.generate(items: items, count: items.length)
10693
end
10794

10895
post '/upload' do

frameworks/sinatra/config.ru

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ class MethodGuard
1818
end
1919

2020
use MethodGuard
21+
use Rack::Deflater
2122
run App

frameworks/sinatra/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"display_name": "sinatra",
33
"language": "Ruby",
4-
"type": "tuned",
4+
"type": "production",
55
"engine": "puma",
66
"description": "Sinatra DSL web framework on Puma, multi-threaded with one worker per CPU core.",
77
"repo": "https://github.com/sinatra/sinatra",

0 commit comments

Comments
 (0)