joshuaflanagan / serverless-ruby-package

serverless plugin to package ruby gems
39 stars 11 forks source link

Deploying with no gems outside of dev group results in all gems packaged #1

Closed lwoodson closed 5 years ago

lwoodson commented 5 years ago

Gemfile contains some development gems:

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

group :development do
  gem "rake"
  gem "rspec"
  gem "pry-byebug"
  gem "rubocop"
end

Relevant serverless.yml:

plugins:
  - serverless-localstack

provider:
  name: aws
  runtime: ruby2.5
  stage: ${opt:stage}
  region: ${opt:region}
  profile: ${opt:profile}

package:
  excludeDevDependencies: false # only applies to node
  include:
    - handlers.rb
    - lib/**

Running sls package and checking the size of the .serverless/<service>.zip file:

-rw-r--r--  1 lwoodson  staff   5.3M Mar 27 14:44 shipit-qbridge.zip

When I add the redis gem to the Gemfile:

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem "redis", "~> 3.3.3"

group :development do
  gem "rake"
  gem "rspec"
  gem "pry-byebug"
  gem "rubocop"
end

Packaging is optimized as expected. Here is the size of the .serverless/<service>.zip file after running sls package again:

-rw-r--r--  1 lwoodson  staff    67K Mar 27 14:46 shipit-qbridge.zip
joshuaflanagan commented 5 years ago

This has been resolved by https://github.com/joshuaflanagan/serverless-ruby-package/commit/a4452200848bebeba59c9aed9e6c1c65a6f2c590 and is available in the 1.1.0 release.