Skip to content

Commit 36f8f78

Browse files
committed
#68 #69 Updated docs for enviorment option and 2.7 examples
1 parent 07ebe3f commit 36f8f78

17 files changed

+167
-212
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,14 @@ custom:
7373

7474
For more detailse refer the docs [here](https://navarasu.github.io/serverless-ruby-layer/#/configuration)
7575

76-
7776
## Usage
7877

7978
Using the custom configuration, the plugin can be utilized for below cases,
8079
* Using locally installed bundler for gems without any native extensions - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/basic) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_local_bundler)
8180
* Using Docker for gems with OS native C extensions or system libraries like `http`, `Nokogiri` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker)
82-
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [PG ruby2.5 Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums-pg-ruby2-5) , [PG ruby2.7 Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums-pg-ruby2-7) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_yums)
83-
* Using Docker with environment variable passthrough - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-env-passthrough) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_env_passthrough)
81+
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [PG Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums-pg-old) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_yums)
8482
* Using Dockerfile for gems which with other OS Linux image or system libraries and utilities - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-file) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_file)
85-
* Using Dockerfile with custom build args - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-file-with-build-args) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_file_with_build_args)
83+
* Using Docker / Dockerfile with environment variable - [Docker Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-environment) - [DockerFile Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-file-with-environment) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/environment)
8684
* Include / Exclude specific functions from layer configuration - [Include Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/include-functions) , [Exclude Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude-functions) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/include_exclude)
8785
* Exclude test and development related gems from layer - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude-dev-test-gems) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/exclude_dev_test_gems)
8886
* Using `Bundler.require(:default)` to require all gems in handler.rb by respecting Gemfile.lock - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/bundler-require-all) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/bundler_require_all)

docs/_sidebar.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
* [Using Local Bundler](use_local_bundler)
77
* [Using Docker Bundler](use_docker)
88
* [Docker with Yums installed](use_docker_with_yums)
9-
* [Docker with ENV passthrough](use_docker_with_env_passthrough)
9+
* [Environment Variables](environment)
1010
* [Using Custom Dockerfile](use_docker_file)
11-
* [Using Custom Dockerfile With Build Args](use_docker_file_with_build_args)
1211
* [Include / Exclude functions](include_exclude)
1312
* [Exclude test gems / development gems](exclude_dev_test_gems)
1413
* [Bundler.require all gems](bundler_require_all)

docs/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ custom:
1212
- postgresql-devel
1313
native_libs:
1414
- /usr/lib64/libpq.so.5
15+
environment:
16+
- GIT_AUTH_SECRET=*****
1517
```
1618
1719
### Configuration Options
@@ -25,4 +27,5 @@ custom:
2527
| **docker_file** | string | undefined | Path of the custom docker file to be used for bundling gems|
2628
| **include_functions** | array | all functions | List of functions to be configured with the gem layer |
2729
| **exclude_functions** | array | no exclude | List of functions to be excluded from layer configuration. <br /> **Note:** `exclude_functions` will be ignored if it is mentioned along with `include_functions`|
30+
| **environment** | array | undefined | List of environment variables to be passed to the docker (bundler/ Gemfile) / dockerfile|
2831
| **ignore_gemfile_lock** | boolean | false | Set true to ignore Gemfile.lock while doing bundle install |

docs/home.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,14 @@ custom:
7373

7474
For more detailse refer the docs [here](https://navarasu.github.io/serverless-ruby-layer/#/configuration)
7575

76-
7776
## Usage
7877

7978
Using the custom configuration, the plugin can be utilized for below cases,
8079
* Using locally installed bundler for gems without any native extensions - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/basic) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_local_bundler)
8180
* Using Docker for gems with OS native C extensions or system libraries like `http`, `Nokogiri` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker)
82-
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [PG ruby2.5 Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums-pg-ruby2-5) , [PG ruby2.7 Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums-pg-ruby2-7) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_yums)
83-
* Using Docker with environment variable passthrough - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-env-passthrough) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_env_passthrough)
81+
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [PG Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums-pg-old) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_yums)
8482
* Using Dockerfile for gems which with other OS Linux image or system libraries and utilities - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-file) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_file)
85-
* Using Dockerfile with custom build args - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-file-with-build-args) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_file_with_build_args)
83+
* Using Docker / Dockerfile with environment variable - [Docker Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-environment) - [DockerFile Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-file-with-environment) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/environment)
8684
* Include / Exclude specific functions from layer configuration - [Include Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/include-functions) , [Exclude Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude-functions) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/include_exclude)
8785
* Exclude test and development related gems from layer - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude-dev-test-gems) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/exclude_dev_test_gems)
8886
* Using `Bundler.require(:default)` to require all gems in handler.rb by respecting Gemfile.lock - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/bundler-require-all) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/bundler_require_all)

docs/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
'/use_local_bundler': '/usage_examples/use_local_bundler',
3333
'/use_docker': '/usage_examples/use_docker',
3434
'/use_docker_with_yums': '/usage_examples/use_docker_with_yums',
35-
'/use_docker_with_env_passthrough': '/usage_examples/use_docker_file_with_env_passthrough',
35+
'/environment': '/usage_examples/environment',
3636
'/use_docker_file': '/usage_examples/use_docker_file',
37-
'/use_docker_file_with_build_args': '/usage_examples/use_docker_file_with_build_args',
3837
'/include_exclude': '/usage_examples/include_exclude',
3938
'/exclude_dev_test_gems': '/usage_examples/exclude_dev_test_gems',
4039
'/bundler_require_all': '/usage_examples/bundler_require_all'

docs/release_notes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release notes
22

3+
### [1.6.0](https://www.npmjs.com/package/serverless-ruby-layer/v/1.6.0)
4+
### Environment Release
5+
* Pass environment variable to docker for bundler/ Gemfile
6+
* Pass environment variable to dockerfile as build args
7+
* Updated examples for ruby2.7 runtime
8+
* Fixed bug in clearing cache folder inside gems folder
9+
310
### [1.5.0](https://www.npmjs.com/package/serverless-ruby-layer/v/1.5.0)
411
### Gemfile.lock Release
512
* Used `Gemfile.lock` is used for bundle install if the file present

docs/usage_examples/bundler_require_all.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ custom:
3434

3535
provider:
3636
name: aws
37-
runtime: ruby2.5
37+
runtime: ruby2.7
3838

3939
functions:
4040
hello:

docs/usage_examples/environment.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
## Passing environment variable
2+
3+
### Using Docker with environment
4+
5+
<!-- tabs:start -->
6+
7+
#### ** serverless.yml **
8+
9+
```yml
10+
service: use-docker-with-enviornment
11+
12+
plugins:
13+
- serverless-ruby-layer
14+
15+
custom:
16+
rubyLayer:
17+
use_docker: true
18+
environment:
19+
- USE_HTTPARTY
20+
- NOKOGIRI_VERSION=1.10.10
21+
22+
provider:
23+
name: aws
24+
runtime: ruby2.7
25+
26+
functions:
27+
hello:
28+
handler: handler.hello
29+
```
30+
31+
#### ** Gemfile **
32+
33+
```ruby
34+
source 'https://rubygems.org'
35+
if ENV['USE_HTTPARTY']
36+
gem 'httparty', '0.18.1'
37+
else
38+
gem 'http'
39+
end
40+
if ENV['NOKOGIRI_VERSION']
41+
gem 'nokogiri', ENV['NOKOGIRI_VERSION']
42+
else
43+
gem 'nokogiri'
44+
end
45+
```
46+
47+
#### ** handler.rb **
48+
49+
```ruby
50+
require 'httparty'
51+
52+
def hello(event:, context:)
53+
body = HTTParty.get("https://github.com").body
54+
55+
{ statusCode: 200, body: body }
56+
end
57+
```
58+
<!-- tabs:end -->
59+
60+
### Using Dockerfile with environment
61+
62+
<!-- tabs:start -->
63+
64+
#### ** serverless.yml **
65+
66+
```yml
67+
service: use-docker-with-enviornment
68+
69+
plugins:
70+
- serverless-ruby-layer
71+
72+
custom:
73+
rubyLayer:
74+
use_docker: true
75+
environment:
76+
- USE_HTTPARTY
77+
- NOKOGIRI_VERSION=1.10.10
78+
79+
provider:
80+
name: aws
81+
runtime: ruby2.7
82+
83+
functions:
84+
hello:
85+
handler: handler.hello
86+
```
87+
88+
#### ** Dockerfile **
89+
```docker
90+
FROM lambci/lambda:build-ruby2.7
91+
92+
RUN gem update bundler
93+
94+
ARG USE_HTTPARTY
95+
ENV USE_HTTPARTY=${USE_HTTPARTY}
96+
ARG NOKOGIRI_VERSION
97+
ENV NOKOGIRI_VERSION=${NOKOGIRI_VERSION}
98+
99+
CMD "/bin/bash"
100+
```
101+
102+
#### ** Gemfile **
103+
104+
```ruby
105+
source 'https://rubygems.org'
106+
if ENV['USE_HTTPARTY']
107+
gem 'httparty', '0.18.1'
108+
else
109+
gem 'http'
110+
end
111+
if ENV['NOKOGIRI_VERSION']
112+
gem 'nokogiri', ENV['NOKOGIRI_VERSION']
113+
else
114+
gem 'nokogiri'
115+
end
116+
```
117+
118+
#### ** handler.rb **
119+
120+
```ruby
121+
require 'httparty'
122+
123+
def hello(event:, context:)
124+
body = HTTParty.get("https://github.com").body
125+
126+
{ statusCode: 200, body: body }
127+
end
128+
```
129+
<!-- tabs:end -->
130+

docs/usage_examples/exclude_dev_test_gems.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ plugins:
2929

3030
provider:
3131
name: aws
32-
runtime: ruby2.5
32+
runtime: ruby2.7
3333

3434
functions:
3535
hello:

docs/usage_examples/include_exclude.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins:
1616

1717
provider:
1818
name: aws
19-
runtime: ruby2.5
19+
runtime: ruby2.7
2020

2121
custom:
2222
rubyLayer:
@@ -96,7 +96,7 @@ plugins:
9696

9797
provider:
9898
name: aws
99-
runtime: ruby2.5
99+
runtime: ruby2.7
100100

101101
custom:
102102
rubyLayer:

0 commit comments

Comments
 (0)