remote: ###### WARNING: remote: You are using the `asset_sync` gem. remote: See https://devcenter.heroku.com/articles/please-do-not-use-asset-sync for more information.
我们试图通过使用AssetSync解决的原始问题是我们的应用程序中的大型资产导致了巨大的段塞大小.在Heroku允许我们的300MB中,我们可能使用接近230MB – 尽管我们的git repo只有80MB左右.
我们通过使用AssetSync将所有已编译资产同步到通过Cloudfront提供的S3存储桶来解决此问题.在AssetSync运行之后,我们有一个钩子可以删除所有预编译资产以减少段塞大小.基本上,slug编译期间的工作流程如下所示:
>让Heroku预编译资产
> AssetSync将所有已编译的资产同步到S3
>删除已编译资产的所有本地副本
Using Asset Sync can cause failures. It is difficult to debug,
unnecessary,and adds extra complexity. Don’t use it. Instead,use a
CDN.[…]
You should now use a CDN instead. Rather than
copying your assets over to S3 after they are precompiled,the CDN
grabs them from your website. Here are some reasons why that’s better.Canonical assets
[…] It allows you to have single,authoritative places where you
store information. If you need to change that information,you only
need to change it in one place. […] What happens if someone has a
Failed deploy after assets get synced? What if someone modifies a file
in the S3 bucket? Instead of fixing one copy of assets,now you must
fix two.Deploy determinism
If you’re debugging inside of a dyno with heroku run bash and you run
rake assets:precompile this doesn’t just modify your local copy. It
actually modifies the copy on S3 as well. […] The sync part of
asset_sync can also fail if there’s a glitch in the network. What if
you only write part of a file,or only half of your assets are synced?
These things happen.
虽然我同意他们的观点,但问题仍然存在:当预编译资产存储在slug中时,部署Heroku应用程序的推荐方法是什么?