LoginSignup
1
1

More than 5 years have passed since last update.

octopressのs3デプロイファイル群をgzip圧縮する

Last updated at Posted at 2014-02-12
Rakefile
deploy_default = "s3"
## -- S3 Deploy config -- #
s3_bucket      = "hugehugehuge"  # Enter your S3 bucket name here
s3_cache_secs  = "3600" # Number of seconds to keep objects in cache - 3600 = 1 hour


desc "Deploy website via s3cmd"
task :s3 do
  (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
  Rake::Task[:copydot].invoke(public_dir, deploy_dir)
  puts "\n## Copying #{public_dir} to #{deploy_dir}"
  cp_r "#{public_dir}/.", deploy_dir
  puts "## Compile css,html,js,xml to gz"
  Dir.glob("#{deploy_dir}/**/*.{css,html,js,xml}") do |f|
    system("gzip -n #{f}")
  end
  system("find #{deploy_dir}/ -iname '*.gz' -exec rename 's/\.gz$//i' {} +")
  puts "## Deploying website via s3cmd"
  ok_failed system("s3cmd sync --acl-public --add-header \"Cache-Control: max-age=#{s3_cache_secs}\" #{deploy_dir}/* s3://#{s3_bucket}/ --exclude '*.sh' --exclude '*.html' --exclude '*.js' --exclude '*.css' --exclude '*.xml' ")
  ok_failed system("s3cmd sync --acl-public --add-header \"Cache-Control: max-age=#{s3_cache_secs}\" --add-header 'Content-Encoding:gzip'  #{deploy_dir}/* s3://#{s3_bucket}/ --exclude '*.*' --include '*.html' --include '*.js' --include '*.css' --include '*.xml'")
end
brew install rename s3cmd

参考
- http://www.furida.mu/blog/2012/02/29/gzip-your-octopress/
- http://blog.nambo.jp/2013/07/25/octopress-aws-s3/

追記
こっちの方がいいかも
http://qiita.com/soramugi/items/568357c49e6cb7ec867e

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1