Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Using Ruby and Capistrano, deploy a static website to an Amazon S3 website bucket.
Ruby

This branch is 48 commits behind hooktstudios:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
certs
lib/capistrano
.gitignore
CONTRIBUTING.md
Gemfile
Gemfile.lock
LICENSE
NEWS
README.md
Rakefile
capistrano-s3.gemspec

README.md

capistrano-s3

Enables static websites deployment to Amazon S3 website buckets using Capistrano.

Dependency Status Code Climate Gem Version

Hosting your website with Amazon S3

Amazon S3 provides special websites enabled buckets that allows you to serve web pages from S3.

To learn how to setup your website bucket, see Amazon Documentation.

Getting started

Create a project Gemfile :

source 'https://rubygems.org'
gem 'capistrano-s3'

Setup

Install gem, init capistrano & create a public folder that will be published :

bundle install
bundle exec capify .
mkdir public

Credentials

Set your S3 bucket credentials :

# config/deploy.rb
require 'capistrano/s3'

set :bucket, "www.cool-website-bucket.com"
set :access_key_id, "CHANGETHIS"
set :secret_access_key, "CHANGETHIS"

Deploying

Add content to you public folder and deploy with :

cap deploy

If you want to deploy to multiple buckets, have a look at Capistrano multistage and configure a bucket per stage configuration.

S3 write options

capistrano-s3 sets files :content_type and :acl to :public_read, add or override with :

set :bucket_write_options, {
    cache_control: "max-age=94608000, public"
}

See aws-sdk S3Object.write doc for all available options.

Exemple of usage

Our Ruby stack for static websites :

  • sinatra : awesome simple ruby web framework
  • sinatra-assetpack : deals with assets management, build static files into public/
  • sinatra-export : exports all sinatra routes into public/ as html or other common formats (json, csv, etc)

Mixing it in a capistrano task :

# config/deploy.rb
before 'deploy' do
  run_locally "bundle exec ruby sinatra:export"
  run_locally "bundle exec rake assetpack:build"
end

See our boilerplate sinatra-static-bp for an exemple of the complete setup.

Contributing

See CONTRIBUTING.md for more details on contributing and running test.

Credits

hooktstudios

capistrano-s3 is maintained and funded by hooktstudios

Something went wrong with that request. Please try again.