I am trying to deploy with capistrano version 3.
I have staging and production servers, after deploying to production, I manually do precompile in the server.
assets compilation takes a lot of time nearly more than half an hour, is there a way to reduce the precompile time, like not compiling unwanted/unchanged files
Turbo sprockets gem may be of some help.
It basically only compiles those files which have changed and not everything, if you don't want that you probably want to know which assets compilation is actually taking time by going through sprockets logs.
Related
I want to change from having Heroku pre-compile the assets to pre-compiling them on development and pushing them to Heroku. I understand the basic procedure is
RAILS_ENV=production bundle exec rake assets:precompile
git add .
git commit -m 'Add precompiled Assets'
git push production master
However, this wipes out any existing assets on heroku. For instance, images referenced in old emails are wiped out. Is there a way to do this and provide a continuity with legacy assets?
Based on some help from Heroku support and the comments from Schneems below, here is the non-answer I came to.
Unless you understand the intricacies of managing your assets with sprockets, precompile on heroku rather than locally.
Whether you precompile locally or heroku, use a CDN and set far future expire dates on your assets.
Use the latest version of sprockets (3.7.1 as the time of writing this post).
If you precompile locally, be aware that sprockets does keep the last three copies of the assets around, and keep in mind it is up to you to keep your assets consistent with the last release.
There are many edge cases, so there is no such thing as a simple answer that suits the stack overflow format.
So in summary, unless you are highly knowledgeable or courageous, do not precompile locally.
And finally, use a CDN.
Using: rails4 app
Command: For Connecting and Rebooting in order to see the change.
rake assets:precompile
and
control + c
rails s
Is it normal!! Because, sometime I have to do a lot of change and I don't want to reboot the rails server 2000 times per hour.
It's development machine.
Suggestions would be appreciated.
I'm not sure why you're precompiling while still making changes to your SASS.
During development, if making frequent changes to SASS, I'll have cleaned my assets out and the server will pick up and compile these changes as I make them.
rake assets:precompile
is only used when I push to production
There is some guidance here: http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation on why you might want to precompile locally, but I can't speak for your own projects.
I had a lot of headaches when trying to edit js files and refresh them while my assets were precompiled and they all went away went I ditched it in dev.
I solve it with this command
rake assets:clobber
Thanks anyway.
I used to develop a project on my own and now I have got some others to help in the project. It's developed with Ruby on Rails and we have a staging server on Heroku. Beforehand the deployment workflow is to precompile the assets in local machine then push the code to heroku. It works well when I am on my own.
Now I am working with a Front-end engineer. The problem is we are working in different location so it is difficult to setup his computer the same as mine. As a result, he will not be able to precompile the code before pushing to heroku.
Of course I can do it for him but would be better if he can just submit the code to the staging server and let Heroku to precompile it. I think Heroku detect if the manifest file is available to determine if it needs to precompile. Is there a way to force Heroku to recompile the assets?
I have tried: heroku run rake assets:clean then heroku run rake assets:precompile but no luck...
Heroku's servers use a read-only file system. This is how they make it easy for you to spin up more dynos, among other things.
Compiling Rails assets means taking the source files and compiling a new file, i.e. writing a file to the file system. Since this can't happen on a read-only file system, you have to precompile first. Even if you did manage to compile assets on Heroku, by writing to the /tmp directory, at the end of the day when Heroku reboots dynos, your new files will be gone because they weren't checked into the repo as they would've been if you had precompiled them locally, committed them, and then pushed to Heroku.
Any workaround I can imagine would be more complicated than helping your front end dev setup Rails and bundle installing the gems needed to precompile before pushing.
I don't know it's just me, or everybody is facing same kinda issue. I am trying to precompile assets on server with this command -
bundle exec rake assets:precompile RAILS_ENV=production
but it takes about 10mins to compile all assets. The project is not big, its just started and has some 5 coffee script files, 3 css files.
Because of this, even capistrano deployments takes longer to complete.
Earlier it was ruby 1.9.2 there, now I am trying with REE 1.8.7.
I am runnning rails 3.1 on my heroku server (but with the bamboo stack).
Since 3.1, I had to add a javascript compiler for uglifier. So I'm using therubyracer-heroku for now.
The reason I'm wondering is that I'm always precompiling my assets, and even pushing them to Amazon S3. So why should I still need a compiler on the host ?
I'm asking because therubyracer is a heavy gem, and so a lot of requests are failing because of memory issues.
A bit late on the answer, but you actually do not need a javascript runtime on the production server, and you should not.
You should turn of compiling on the server with : config.assets.compile = false
And precompile all the assets before deploying.