Skip to content
Static website using https with your own domain name using Amazon S3 and Cloudflare for FREE
Ruby HTML CSS Shell
Branch: master
Clone or download

Latest commit

Latest commit 5287de6 Mar 8, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Feb 29, 2020
bin preparing for a release Mar 8, 2020
docs added gif file Mar 8, 2020
lib preparing for a release Mar 8, 2020
spec WIP Jun 12, 2019
template template & generator Dec 18, 2019
.gitignore added gif file Mar 8, 2020
.rspec WIP Jun 12, 2019
.travis.yml WIP Jun 12, 2019
Gemfile WIP Jun 12, 2019
Gemfile.lock preparing for a release Mar 8, 2020
LICENSE.txt WIP Jun 12, 2019
README.md Update README.md Mar 8, 2020
Rakefile WIP Jun 12, 2019
TASKS.md integration with cloudflare Jun 21, 2019
amazon_static_site-0.1.0.gem template & generator Dec 18, 2019
amazon_static_site.gemspec preparing for a release Mar 8, 2020

README.md

Static Site using Amazon S3 + Cloudflare + HTTPS

Upload static HTML/CSS/JS to the Amazon S3 and host HTTPS website for free using Cloudflare.

This tool allows you to upload a folder with your files to S3, configure for you Cloudflare account and map it all together so you will get a site with HTTPS.

This gem was used to deploy my site to production. So it's ready for everyday use.

DEMO

demo upload file to s3

Installation

  1. Install gem:
  $ gem install amazon_static_site

And run

  amazon_static_site generate site123
  cd site123

Edit config.yml.

  1. You need to have account on Amazon, you need to get API access_key_id and secret_access_key from Amazon: https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html

  2. You need to have an account on https://www.cloudflare.com/, and copy API-key from settings: https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys

  3. You need to configure settings file, where you need to put your Amazon S3 keys, Cloudflare keys, and settings for a domain.

  4. Run this CLI amazon_static_site deploy <path-to-config> <path-to-public-folder>

  5. Check the previous logs, you will see settings for nameservers which you need to put (one time) on your hosting provider (where you host your domain), and wait few minutes/hours until DNS will be updated.

  6. You could make a changes to the HTML/CSS/JS and re-upload files. This time, you don't need to change nameservers.

Usage

amazon_static_site deploy ./template/config.yml ./template/public

You can use generator amazon_static_site generate <app>.

Local development

amazon_static_site serve ./template/config.yml ./template/public

Options

domain:
  primary: "www.railsjazz.com"
  secondary: "railsjazz.com"
s3:
  region: us-west-1
  access_key_id: "XXXXXXXXXXXXXXXXXXXXXXX"
  secret_access_key: "YYYYYYYYYYYYYYYYYYYYYYYYYYYY"
cloudflare:
  email: my@email.com
  api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

React app

For example you can create React app using create-react-app, do some coding, after this run yarn build and then copy files from build/* to the public folder to the generated amazon_static_site path. Or specify this build folder as public folder option.

amazon_static_site deploy ./config.yml /path/to/react-app/build

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

TODO

  • Check "non-www" domains
  • Tests
  • Better documentation

Contributing

You are welcome to contribute.

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.