OHO's Blog

My 2 cents about everything!

Deploy Octopress Blog to Amazon S3

Octopress blog system is an interesting approach to have a robust fast and easily indexable web site. It’s even more interesting to have it hosted on Amazon S3 for reliability and peace of mind as you would not have to host it yourself.

So here is my quick howto tweak for moving mine to S3 using aws sync command.

Great article to help me set this up

I was looking at howto set this up on Google and found this article from Ryan Jones that explained very well the howto.

Unfortunately, I counldn’t use the s3cmd tool from Github needed to sync Octopress, so I changed a bit the approach to use Amazon aws CLI.

That’s what is all about on this quick article. it’s my 2 cents to Ryan article …

Replacing s3cmd by aws CLI

Of course I’ll not go into details of how to setup Amazon S3 service nor Amazon aws CLI.

Idea here is to quickly share what worked for me in changing my Rakefile

Rakefile

So at the end or your Rakefile, in stead of using Ryan’s code, here is mine:

Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#...
# Somewhere at the bigining of Rakefile
deploy_default = "s3" # before migrating to S3 it was set to "rsync" for instance
s3_bucket       = "blog.hoachuck.biz"
aws_cli_path    = "/Users/me/.virtualenv/python3.3/bin/aws" # path to your installed aws CLI
aws_region      = "us-east-1" # the bucket is set to US
aws_read_mode   = "uri=http://acs.amazonaws.com/groups/global/AllUsers" # needed to set upload rights so that everybody will have access to the content

# ...


# At the enf of your Rakefile, set your "s3" processing
desc "Deploy website via aws s3 sync"
task :s3 do
  puts "## Deploying website via aws s3 sync"
  ok_failed system("#{aws_cli_path} s3 sync public/ s3://#{s3_bucket}/ --region #{aws_region} --grants read=#{aws_read_mode}")
end

Comments