serverless-rack 1.0.1 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +26 -3
- data/lib/serverless_rack.rb +20 -16
- data/serverless-rack.gemspec +4 -2
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67c45bfb333ad3b27bd1d7f36e5b98ecc7ead2f27762a9ddc1c713b7d2cc5a9b
|
4
|
+
data.tar.gz: 9db88c7bf781a67032fb866886d443ff219140427ce1087e667d836a39f9271a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dbfe05405a816ae2a31e62a3046253f842616e72b3ca3aa0149e337f97d59e75127f3d513b657f2357e94c1c31a11701f352b2d82c75a22843f296dd388f988
|
7
|
+
data.tar.gz: 75b78e2e61ab8fcba27b75ac33c4cf328049b26ea97ff3480b4049e013d4b25d7a89c4e17896c57f08cd9f90ea53a6cdab196e97c1ba2d009888e32d23fc3bfd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1
|
+
# 1.0.6
|
2
|
+
|
3
|
+
- Upgrade dependencies
|
4
|
+
- Add a dockerImage config option to override the docker image to be used for compiling gems (defaults to the lambci ruby images) (#17)
|
5
|
+
|
6
|
+
_Benjamin Curtis_
|
7
|
+
|
8
|
+
- Cache the bundle that is created by docker to avoid recompiling gems (#17)
|
9
|
+
|
10
|
+
_Benjamin Curtis_
|
11
|
+
|
12
|
+
- Handle empty `API_GATEWAY_BASE_PATH` (#14)
|
13
|
+
|
14
|
+
_Joel Van Horn_
|
15
|
+
|
16
|
+
# 1.0.5
|
17
|
+
|
18
|
+
- Upgrade dependencies
|
19
|
+
|
20
|
+
# 1.0.4
|
21
|
+
|
22
|
+
- Support `configPath` option when invoking `sls rack serve` (#5)
|
23
|
+
|
24
|
+
# 1.0.3
|
25
|
+
|
26
|
+
- Upgrade dependencies
|
27
|
+
|
28
|
+
# 1.0.2
|
29
|
+
|
30
|
+
- Remove `BUNDLED WITH` from Gemfile to allow using different version of
|
31
|
+
Bundler from the one provided by AWS Lambda (#3)
|
32
|
+
- Add `configPath` option for setting path to `config.ru` (#4)
|
33
|
+
|
34
|
+
_Yousaf Nabi_
|
35
|
+
|
1
36
|
# 1.0.1
|
2
37
|
|
3
38
|
- Support additional bundler arguments to be passed when using docker (#2)
|
data/README.md
CHANGED
@@ -139,13 +139,23 @@ For more information, see https://bundler.io/docs.html.
|
|
139
139
|
|
140
140
|
If your application depends on any gems that include compiled binaries, these
|
141
141
|
must be compiled for the lambda execution environment. Enabling the `dockerizeBundler` configuration
|
142
|
-
option will fetch and build the gems using a
|
143
|
-
that emulates the lambda environment:
|
142
|
+
option will fetch and build the gems using a docker image that emulates the lambda environment:
|
144
143
|
|
145
144
|
```yaml
|
146
145
|
custom:
|
147
146
|
rack:
|
148
|
-
dockerizeBundler:
|
147
|
+
dockerizeBundler: true
|
148
|
+
```
|
149
|
+
|
150
|
+
The default docker image that will be used will match the runtime you are using.
|
151
|
+
That is, if you are using the `ruby2.7` runtime, then the docker image will be
|
152
|
+
`logandk/serverless-rack-bundler:ruby2.7`. You can override the docker image with the
|
153
|
+
`dockerImage` configuration option:
|
154
|
+
|
155
|
+
```yaml
|
156
|
+
custom:
|
157
|
+
rack:
|
158
|
+
dockerImage: lambci/lambda:build-ruby2.5
|
149
159
|
```
|
150
160
|
|
151
161
|
### Bundler configuration
|
@@ -181,6 +191,17 @@ custom:
|
|
181
191
|
bundlerBin: /path/to/bundler
|
182
192
|
```
|
183
193
|
|
194
|
+
### Rack configuration file
|
195
|
+
|
196
|
+
If your Rack configuration file (`config.ru`) is not in `./`, set the path explicitly using the `configPath`
|
197
|
+
configuration option:
|
198
|
+
|
199
|
+
```yaml
|
200
|
+
custom:
|
201
|
+
rack:
|
202
|
+
configPath: path/to/config.ru
|
203
|
+
```
|
204
|
+
|
184
205
|
### Local server
|
185
206
|
|
186
207
|
For convenience, a `sls rack serve` command is provided to run your Rack application
|
@@ -208,6 +229,8 @@ $ sls rack serve -p 8000
|
|
208
229
|
When running locally, an environment variable named `IS_OFFLINE` will be set to `True`.
|
209
230
|
So, if you want to know when the application is running locally, check `ENV["IS_OFFLINE"]`.
|
210
231
|
|
232
|
+
For use with the `serverless-offline` plugin, run `sls rack install` prior to `sls offline`.
|
233
|
+
|
211
234
|
### Remote command execution
|
212
235
|
|
213
236
|
The `rack exec` command lets you execute ruby code remotely:
|
data/lib/serverless_rack.rb
CHANGED
@@ -15,17 +15,19 @@ TEXT_MIME_TYPES = [
|
|
15
15
|
'image/svg+xml'
|
16
16
|
].freeze
|
17
17
|
|
18
|
+
def base_path
|
19
|
+
"/#{ENV['API_GATEWAY_BASE_PATH']}" unless ENV['API_GATEWAY_BASE_PATH'].to_s.empty?
|
20
|
+
end
|
21
|
+
|
18
22
|
def keepalive_event?(event)
|
19
23
|
['aws.events', 'serverless-plugin-warmup'].include?(event['source'])
|
20
24
|
end
|
21
25
|
|
22
26
|
def parse_script_name(event, headers)
|
23
|
-
if
|
24
|
-
"/#{ENV['API_GATEWAY_BASE_PATH']}"
|
25
|
-
elsif (headers['Host'] || '').include?('amazonaws.com')
|
27
|
+
if base_path.nil? && (headers['Host'] || '').include?('amazonaws.com')
|
26
28
|
"/#{event['requestContext']['stage']}"
|
27
29
|
else
|
28
|
-
|
30
|
+
base_path.to_s
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -33,12 +35,11 @@ def parse_path_info(event)
|
|
33
35
|
# If a user is using a custom domain on API Gateway, they may have a base
|
34
36
|
# path in their URL. This allows us to strip it out via an optional
|
35
37
|
# environment variable.
|
36
|
-
if
|
37
|
-
|
38
|
-
|
38
|
+
if base_path && event['path'].start_with?(base_path)
|
39
|
+
event['path'][base_path.length..-1]
|
40
|
+
else
|
41
|
+
event['path']
|
39
42
|
end
|
40
|
-
|
41
|
-
event['path']
|
42
43
|
end
|
43
44
|
|
44
45
|
def parse_query_string(event)
|
@@ -59,9 +60,11 @@ end
|
|
59
60
|
|
60
61
|
def parse_headers(event)
|
61
62
|
if event.include? 'multiValueHeaders'
|
62
|
-
Rack::Utils::HeaderHash.new(
|
63
|
-
[
|
64
|
-
|
63
|
+
Rack::Utils::HeaderHash.new(
|
64
|
+
(event['multiValueHeaders'] || {}).transform_values do |value|
|
65
|
+
value.join("\n")
|
66
|
+
end
|
67
|
+
)
|
65
68
|
else
|
66
69
|
Rack::Utils::HeaderHash.new(event['headers'] || {})
|
67
70
|
end
|
@@ -166,11 +169,12 @@ end
|
|
166
169
|
|
167
170
|
def format_split_headers(headers:)
|
168
171
|
headers = headers.to_hash
|
172
|
+
keys = headers.keys
|
169
173
|
|
170
174
|
# If there are headers multiple occurrences, e.g. Set-Cookie, create
|
171
175
|
# case-mutated variations in order to pass them through APIGW.
|
172
176
|
# This is a hack that's currently needed.
|
173
|
-
|
177
|
+
keys.each do |key|
|
174
178
|
values = headers[key].split("\n")
|
175
179
|
|
176
180
|
next if values.size < 2
|
@@ -187,9 +191,9 @@ def format_split_headers(headers:)
|
|
187
191
|
end
|
188
192
|
|
189
193
|
def format_grouped_headers(headers:)
|
190
|
-
{ 'multiValueHeaders' => headers.
|
191
|
-
|
192
|
-
end
|
194
|
+
{ 'multiValueHeaders' => headers.transform_values do |value|
|
195
|
+
value.split("\n")
|
196
|
+
end }
|
193
197
|
end
|
194
198
|
|
195
199
|
def format_response(event:, status:, headers:, body:, text_mime_types:)
|
data/serverless-rack.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'serverless-rack'
|
3
|
-
s.version = '1.0.
|
5
|
+
s.version = '1.0.6'
|
4
6
|
s.summary =
|
5
7
|
'Serverless plugin to deploy Ruby Rack applications (Sinatra/Padrino/Cuba etc.) '\
|
6
8
|
'and bundle gems'
|
@@ -21,6 +23,6 @@ Gem::Specification.new do |s|
|
|
21
23
|
s.homepage = 'https://github.com/logandk/serverless-rack'
|
22
24
|
s.license = 'MIT'
|
23
25
|
|
24
|
-
s.required_ruby_version = '>= 2.
|
26
|
+
s.required_ruby_version = '>= 2.4.0'
|
25
27
|
s.add_dependency 'rack', '~> 2.0'
|
26
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverless-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Raarup
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -50,15 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.4.0
|
54
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
|
-
|
61
|
-
rubygems_version: 2.7.6
|
60
|
+
rubygems_version: 3.1.2
|
62
61
|
signing_key:
|
63
62
|
specification_version: 4
|
64
63
|
summary: Serverless plugin to deploy Ruby Rack applications (Sinatra/Padrino/Cuba
|