Google App Engine 资产管道标准环境

Google App Engine asset pipeline standard environment

当应用程序部署到标准(非灵活)环境时,是否可以在 Google App Engine 中的 Rails 资产管道上使用 Ruby?我知道在部署到灵活环境时会发生预编译,但我无法让它在标准环境中工作。

有可能。在此处查看完整文档:Ruby in the App Engine Standard Environment.

请注意,Ruby 标准环境处于 Beta 阶段,因此请记住它可能会随着时间的推移而改变。

问题是 app.yaml 的默认配置阻止将关键文件上传到 GAE。

具体来说,skip_files 部分有一些默认值会阻止所有点文件被上传,包括 sprockets 清单文件:/public/assets/.sprockets-manifest-5y483543959430890.json。如果没有这个文件,Rails 假定资产没有被预编译。

您需要覆盖默认的 skip_files 配置,使其不会阻止上传链轮清单,但仍会阻止 .git/*.

之类的内容

这对我有用,但我相信它可以进一步完善:

skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\.git/.*$

您可以创建一个 .gcloudignore 文件并为 /public/assets 添加一行,而不是使用 app.yaml 的 skip_files 部分。如果这个目录不存在,docs 说:

The Ruby runtime executes rake assets:precompile during deployment to generate static assets and sets the RAILS_SERVE_STATIC_FILES environment variable to enable static file serving in production.