diff --git a/README.md b/README.md index 7a977b0..4eeba8d 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docs/home.md b/docs/home.md index 5ce0a4f..8682211 100644 --- a/docs/home.md +++ b/docs/home.md @@ -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) diff --git a/docs/usage_examples/main.md b/docs/usage_examples/main.md index a3a13cd..e4a3173 100644 --- a/docs/usage_examples/main.md +++ b/docs/usage_examples/main.md @@ -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) + diff --git a/docs/usage_examples/use_docker_with_yums.md b/docs/usage_examples/use_docker_with_yums.md index 75e8532..e5c7c5d 100644 --- a/docs/usage_examples/use_docker_with_yums.md +++ b/docs/usage_examples/use_docker_with_yums.md @@ -2,6 +2,7 @@ ## Preinstall yum packages for gems which requires OS native system libraries +### Example to deploy pg using Ruby 2.7 @@ -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: @@ -54,6 +61,57 @@ end +### Example to deploy pg using Ruby 2.5 + + + +#### ** 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 + +``` + + #### Checkout above Example here @@ -61,13 +119,26 @@ end ```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 @@ -81,4 +152,4 @@ Running `sls deploy` automatically deploys the required gems as in Gemfile to AW ```bash sls invoke -f hello -``` \ No newline at end of file +```