Showing posts with label capistrano. Show all posts
Showing posts with label capistrano. Show all posts

Monday, January 4, 2016

capistrano is slow, alternative: blazing

capistrano seems to be quite slow to deploy. it works great for production, as it export entire git into independent directory and relink directory from shared directory.

In some of my smaller projects,  i would prefer to maintain only 1 folder, and do a git hard reset and push the update directly from my local git.
my work around is to use blazing. since blazing 0.5, recipes is no longer supported.
blazing by default works great! but until you realize you are using spring, and passenger

ive customize blazing with spring generated bin removed from bin.

https://github.com/u007/blazing

to deploy:
  1. create to $HOME/rails/shared
  2. upload shared/config/application.yml (for figaro)
  3. mkdir shared/log
  4. mkdir shared/public/uploads
  5. mkdir shared/public/system
  6. mkdir shared/tmp
  7. mkdir shared/vendor/bundle

next, in your project,
  1. blazing init
  2. edit config/blazing.rb
    rake :"server:deploy"
  3. copy this file to lib/tasks/
    http://pastebin.com/13cTyvGg #if you use mod passenger
  4. blazing setup production
    # this will deploy git after deploy scripts on server
  5. blazing update production # to update later if changed blazing config

to deploy updates, simply:
  1. git push production master # remote: production, local branch: master

Thursday, May 21, 2015

deploying to production via capistrano with passenger and sub uri

due to digested assets requirement in production environment,
the url of images cannot be use in relative to path to css file.

example normal assets:
/assets/frontend/all.css

example of digested assets

/assets/all.XXX.css

due to this, the only way to accurately point to images in css is to add relative path to the url.
one way todo it is to use ENV['RAILS_RELATIVE_URL_ROOT'],
first, you will need to change .css file to .css.erb.
and add in <%=ENV['RAILS_RELATIVE_URL_ROOT']%> to the url path.
example: background-image: url('<%=ENV['RAILS_RELATIVE_URL_ROOT']%>/img/logo.png');

but since we are precompiling via capistrano, it is a must to add this environment into deploy/production.rb
example:
set :bundle_flags, '--deployment' # set this to ensure traces of assets compilation can be shown via --trace
set :default_env, {
  'RAILS_RELATIVE_URL_ROOT' => '/shop'
}

and then run:
cap production deploy --trace

took me hours to try to figure all the issues in place to resolve this.
hope it helps you :)