Deploy static assets to Amazon S3
What is the easiest way to deploy static assets (JavaScript, Images, CSS, …) to Amazon S3? Is ther开发者_如何学Goe any perfect solution?
With "perfect" I mean: git push heroku master
is the only thing I would have to do to get both my code pushed to Heroku and my assets uploaded to S3.
I don't think you're going to be able to do it 'perfectly' just using git.
What may be more use is to use something like the Heroku San plugin and use the after_deploy task to move your assets to their final resting places perhaps?
Although, aren't static assets best suited on Heroku so you can take advantage of the caching it makes use of? We typically commit all js, css and images for layout to git and deploy to Heroku whilst user assets are uploaded to S3.
I think you're going to be better off scripting this locally. One option, create a rake task that takes care of this for you (so you have access to all your gems and dependencies which should make this a simple matter of programming) and run it locally just before you push to heroku. Should be easy enough to automate.
Now you could use the AssetSync gem, that upload all your assets to an Amazon S3 bucket after precompile the assets (automatically when deployed on Heroku):
https://github.com/rumblelabs/asset_sync/
精彩评论