Skip to content

Commit

Permalink
#38 Updated docs with both pg deploy example with both ruby 2.5 and r…
Browse files Browse the repository at this point in the history
…uby 2.7
  • Loading branch information
navarasu committed May 15, 2021
1 parent 81fbfa1 commit 20a9608
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ For more detailse refer the docs [here](https://navarasu.github.io/serverless-ru
Using the custom configuration, the plugin can be utilized for below cases,
* 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)
* 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)
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_yums)
* 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)
* 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)
* 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)
* 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)
Expand Down
2 changes: 1 addition & 1 deletion docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ For more detailse refer the docs [here](https://navarasu.github.io/serverless-ru
Using the custom configuration, the plugin can be utilized for below cases,
* 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)
* 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)
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-with-yums) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_yums)
* 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)
* 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)
* 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)
* 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)
Expand Down
10 changes: 6 additions & 4 deletions docs/usage_examples/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
## Usage and Examples

Using the custom configuration, the plugin can be utilized for below cases,
* Using locally installed bundler for gems without any native extensions [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/basic) - [Docs](/use_local_bundler)
* Using Docker for gems with C extensions or system libraries like `http`, `Nokogiri` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker) - [Docs](use_docker)
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker_with_yums) - [Docs](use_docker_with_yums)
* Using Dockerfile for gems which requires other system libraries and configuration - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker_file) - [Docs](use_docker_file)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)

77 changes: 74 additions & 3 deletions docs/usage_examples/use_docker_with_yums.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Preinstall yum packages for gems which requires OS native system libraries

### Example to deploy pg using Ruby 2.7

<!-- tabs:start -->

Expand All @@ -20,10 +21,16 @@ custom:
- postgresql-devel
native_libs:
- /usr/lib64/libpq.so.5
- /usr/lib64/libldap_r-2.4.so.2
- /usr/lib64/liblber-2.4.so.2
- /usr/lib64/libsasl2.so.3
- /usr/lib64/libssl3.so
- /usr/lib64/libsmime3.so
- /usr/lib64/libnss3.so

provider:
name: aws
runtime: ruby2.5
runtime: ruby2.7

functions:
hello:
Expand Down Expand Up @@ -54,20 +61,84 @@ end
<!-- tabs:end -->


### Example to deploy pg using Ruby 2.5

<!-- tabs:start -->

#### ** serverless.yml **

```yml
service: using-docker-yums

plugins:
- serverless-ruby-layer

custom:
rubyLayer:
use_docker: true
docker_yums:
- postgresql-devel
native_libs:
- /usr/lib64/libpq.so.5

provider:
name: aws
runtime: ruby2.5

functions:
hello:
handler: handler.hello
```

#### ** Gemfile **

```ruby
source 'https://rubygems.org'
gem 'pg'
```

#### ** handler.rb **

```ruby
require 'pg'

def hello(event:, context:)
{ statusCode: 200, body: {
"pg_version": PG.library_version
}
}
end

```

<!-- tabs:end -->

#### Checkout above Example here


```bash
git clone https://github.com/navarasu/serverless-ruby.git
```
*Ruby 2.7*

```bash
cd serverless-ruby/deploy_pg_gem
cd serverless-ruby/deploy_pg_gem_2-7

sls plugin install -n serverless-ruby-layer

```

*Ruby 2.5*

```bash
cd serverless-ruby/deploy_pg_gem_2-5

sls plugin install -n serverless-ruby-layer

```



#### Deploy to AWS

```bash
Expand All @@ -81,4 +152,4 @@ Running `sls deploy` automatically deploys the required gems as in Gemfile to AW

```bash
sls invoke -f hello
```
```

0 comments on commit 20a9608

Please sign in to comment.