Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy static assets to Amazon S3

What is the easiest way to deploy static assets (JavaScript, Images, CSS, …) to Amazon S3? Is there 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.

like image 268
d135-1r43 Avatar asked Feb 18 '11 10:02

d135-1r43


2 Answers

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.

like image 138
John Beynon Avatar answered Sep 27 '22 18:09

John Beynon


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.

like image 35
chris.baglieri Avatar answered Sep 27 '22 17:09

chris.baglieri