this post will intro how ikcrm try to use qiniu cdn speed site's asset file.
references:
- 镜像存储
- https://ruby-china.org/topics/14552
- http://kb.qiniu.com/how-to-use-image-storage-and-qrsync
- https://github.com/ruby-china/ruby-china/commit/d050f7f8b7441fbd88671e0008205f4ccffca8b5
- capistrano/bundler#45
depend tools;
- capistrano
- figaro
- rails
- qrsync
-
ensure figaro, capistrano within your Gemfile, and runed
bundle install
-
place
qrsync
execute file withinrails_root_path/bin
-
create qrsync file config file within
rails_root_path/config
create file rails_root_path/config/qrsync.json create file rails_root_path/config/qrsync.json.example -
install figaro by type
figaro install
ensure file rails_root_path/config/application.yml ensure file rails_root_path/config/application.yml.example
production:
asset_host: "http://assets.example.com"
- update
.gitignore
file
config/qrsync.json
# Ignore application configuration
/config/application.yml
-
update
deploy.rb
file to define task to sync asset file -
config
qiniu_cdn
flag within deploy stage file -
try to load
asset_host
from figrao
- 多个项目使用相同的 七牛 bucket 做 cdn 是个坑, 因此最好 每个项目使用单独的 bucket,t 同时因为 rails 的资源文件 是有 签名串 的, 因此理论上同一个项目不同 stage 的 资源文件放在一个 bucket 里面是可行的