【发布时间】:2020-08-04 22:06:06
【问题描述】:
我正在构建一个 Ruby 2.7 Lambda 应用程序。
我的应用程序依赖于 github 中的 gem。
gem 'my-gem', git: 'https://github.com/my-org/my-gem', branch: 'main'
我想编写一个脚本,可以构建一个包含此依赖项的部署 zip 文件。
当我运行 bundle install 时,我的 gem 安装到 vendor/bundle/ruby/2.7.0/bundler/gems/my-gem-GITHASH。
对于 Lambda 打包,我认为我需要构建以下内容
- vendor/bundle/ruby/2.7.0/gems/my-gem-1.0.0/*(红宝石代码)
- vendor/bundle/ruby/2.7.0/specifications/my-gem-1.0.0.gemspec
以下脚本操作可以组装此结构,但我希望我有一个更简单的方法。
cd vendor/bundle/ruby/2.7.0/bundler/gems/my-gem-*
# build the git gem (*.gem)
gem build
# copy the gem and the gemspec to the vendor/bundle/ruby/2.7.0 directories
cp *.gem ../../../gems
cp *.gemspec ../../../specifications/my-gem-1.0.0.gemspec
# upack the .gem file in the proper directory
cd ../../../gems
gem unpack *.gem
# return to the working directory
cd ../../../../..
# Zip the dependencies
zip -r deploy.zip \
vendor/bundle/ruby/2.7.0/gems \
vendor/bundle/ruby/2.7.0/specifications \
vendor/bundle/ruby/2.7.0/extensions \
lib
我很想找到一个更简单的方法来解决这个问题。
【问题讨论】:
标签: ruby aws-lambda rubygems