gpt4 book ai didi

ruby-on-rails - Heroku Pipelines + Amazon Cloudfront 和多种环境

转载 作者:行者123 更新时间:2023-12-04 05:40:28 26 4
gpt4 key购买 nike

我已经使用 Heroku Pipelines 设置了一个 Rails 应用程序,以便能够自动将我们的暂存环境提升到生产环境。 master push -> CI run -> staging deploy -> production促进的工作流程对我们来说非常有效。

我们的 Assets 正在通过 Amazon Cloudfront 分发。我为临时环境和生产环境设置了单独的分发版,我在环境中配置了这些分发版:

# Environment variable configured per environment
config.action_controller.asset_host = ENV['ASSET_HOST']

这种设置出现了一个问题。即使我配置了 asset_host对于每个环境, Assets 都在临时环境中进行预编译,并且在使用 Heroku Pipelines 进行推广时,也将在生产中使用。这会导致我们的自定义字体 CORS 出现问题。

我想过为多个来源配置单个 Cloudfront 发行版,但无法弄清楚。另外,我真的很想保留我们当前的工作流程,因为它为我们启用了 CD。

最佳答案

将临时环境和生产环境作为源和行为来配置 Cloudfront 是解决方案。

为此,用于登台和生产的 Assets 主机应该是相同的。

Heroku explains这很好:

For many applications sharing a CDN between staging and production is surprising, however causes no problems. You can manually configure both to have the same “asset_host”. This works because even if the copy of the assets has been modified on the staging app, all assets are fingerprinted, and the “production” app will point browsers at the correct fingerprints. The staging app will serve up to 3 old copies of assets, and the CDN should keep assets cached indefinitely.

关于ruby-on-rails - Heroku Pipelines + Amazon Cloudfront 和多种环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37653073/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com