Fresc source code is hosted at Github and we use the classical Git branching model: we create branches for almost every features, everything is then merged on our development branch - called
pending - and when we are ready to deploy, we merge everything to the
master branch using Pull Requests.
Following defunkt's blog post on improving Capistrano deploy task when working with Git, we were deploying in 7 seconds - excluding Resque workers and scheduler restart time -.
This was true before Rails 3.1.
Rails 3.1 brought us the assets pipeline, which is awesome. But there was one major counterpart, when deploying Capistrano was now always running the
rake assets:precompile task which made our deployment time increasing from 7 seconds to almost 8 minutes.
Compile only what needs to be compiled.
In order to reduce the amount of time spent precompiling assets, we used a snippet from @iwinux to customize the way the precompiler should behave in order to ignore any file starting with a
_. We adopted this naming convention for both JS and CSS files and now any included only files are starting with
This made us reducing deployment time from 8 to 4 minutes. Still, that was far from our previous 7 seconds to deploy.
rails-precompile2git : assets precompilation daemon
We explored another possibility, why not removing the precompilation task from capistrano deployment task and alias git to run the precompilation task when pushing. We were back to our 7 seconds deployment time but we quickly figured out that this was counter productive. Git is about being fast and we just had made it really SLOW.
Then, we finally though about another approach. Why not making a daemon that would do the job for us, automatically? We developed the idea and published rails-precompile2git.
On each new commit on a given branch, rails-precompile2git will:
- break any currently running
rake assets:precompiletask, hard reset branches
- fetch changes, merge them to destination branch
- git add/commit everything
- push to remote destination branch
We now make our Pull Requests from the development branch to a branch called
premaster, which is the branch being watched by our rails-precompile2git instance, which runs the precompilation task and push back to the
master branch. With rails-precompile2git we are now back to our 7 seconds deployment time.