Coder Social home page Coder Social logo

elado / capistrano-s3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from capistrano-s3/capistrano-s3

0.0 2.0 0.0 394 KB

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

Home Page: https://rubygems.org/gems/capistrano-s3

License: Other

capistrano-s3's Introduction

capistrano-s3

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

Build Status 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

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

Setup

Install gems with bundle, init capistrano & create your public folder that will be published :

bundle install
bundle exec capify .
mkdir public

Deploy configuration

Replace deploy.rb content generated by capify with these simple Amazon S3 configurations :

# 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 run cap deploy.

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

Advanced options

Custom endpoint

If your bucket is not in the default US Standard region, set endpoint with :

set :s3_endpoint, 's3-eu-west-1.amazonaws.com'

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 S3Client.put_object doc for all available options.

Redirecting

Use :redirect_options to natively redirect (via HTTP 301 status code) any hosted page. For example:

set :redirect_options, {
  'index.html' => 'http://example.org',
  'another.html' => '/test.html',
}

Valid redirect destination should either start with http or https scheme, or begin with leading slash /.

Example 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 example 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

Thanks & credits also to all other contributors.

capistrano-s3's People

Contributors

aleksandrs-ledovskis avatar barvaz avatar brianknight10 avatar douglasjarquin avatar inkblot avatar j15e avatar ryanstout avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.