0.0
No commit activity in last 3 years
No release in over 3 years
publish2cloud
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme
==What it is for==
You have a running rails application, but some of the content do not change often (company frontpage, marketing materials etc). And you are thinking about taking advantage of Amazon's cloudfront service for better speed and reliability.

Publish2Cloud is a ruby gem that help you to move the content to the cloud (Amazon's cloudfront cdn service). It does NOT encourge/force you to write static html like the old days, you will keep your database driven rails site running. But if the rendered content does not change often, this gem can pull the content from your site and push them to cloudfront, along with some DNS help, those content will be served faster and more reliably.

==What it does==
Assuming your site is running at 'www.company.com', and you enabled cloudfront on bucket 'company-cdn' and assigned a CNAME 'cdn.company.com'. And on 'www.company.com', there are some contents that rarely changes, for example:
http://www.company.com/contract

You can use publish2Cloud's rake task to fecth 'http://www.company.com/contract', and upload it to 'company-cdn' (invalidate the original one from the cloud if already exists), so that you can have the content at:
http://cdn.company.com/contract

==Install==
gem install publish2cloud

With Rails 3, add this line into Gemfile
group :development do
  gem 'publish2cloud'
end

==Usage==
You need a amazon aws account, and enable s3 and cloudfront service.

Create config/publish2cloud.rb in your rails projects, and make it look like this:
P2C_S3_ACCESS_KEY_ID=''
P2C_S3_SECRET_ACCESS_KEY=''
P2C_S3_BUCKET=''
#Optional
#P2C_MAX_AGE=86400
#This is not one in .cloudfront.net url
P2C_CF_DISTRIBUTION_ID=''
#This file a just a ruby program, feel free modify P2C_URLS with code
P2C_URLS=['', '']

Run it:
rake p2c:push

In the future, you will need to run 'rake p2c:push' each time when the cached content changes (new deployment, data being updated in database etc).

==Thanks and Credits==
I used some code of jmlacroix, and his original post is at:
http://jmlacroix.com/archives/cloudfront-hosting.html
http://jmlacroix.com/archives/cloudfront-publishing.html

I also used heroku_san's code as a reference to add rake task into a gem:
https://github.com/fastestforward/heroku_san

==License==
Copyright 2011 Intridea Inc ( http://intridea.com ), released under the MIT license.