Static site deployment script
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


fog_site is a simple utility gem for deploying a static site to Amazon S3 and CloudFront using the fog gem.

To make deployments fast, this gem calculates the MD5 sum of every file locally and compares them against the information stored on S3 (in the 'etag' property of the S3 object). Files are only uploaded if the etag has changed.


Create a new site

site = ""

Decide what you want to deploy

site.path = "/home/bpo/stovepipe"

Decide whether to destroy resources that aren't local

site.destroy_old_files = true

If you're using CloudFront, specify a distribution ID:

site.distribution_id = "Z99120CAFEBABE"

You can set headers on a global level

site.headers = { 'Expires' => '0' }

And push it to the cloud


All local settings for a site can be passed into the new_site method: "", :path => "/home/bpo/stovepipe",
                                         :destroy_old_files => true

AWS credentials are read from the environment variables AWSAccessKeyId and AWSSecretKey, but can also be set programmatically:

site = ""
site.access_key_id = "E7L8CCM59BFXJOAMEAPT"
site.secret_key = "t5nszajv3y8u4zI/LtP/r5xUmPnqAT/Tv2n7Xr7n"



We use this tool internally at Stovepipe Studios to manage our static domain deployments. We have a simple Rake script with a task for each of our different sites - each task builds a FogSite and has the configuration variables set according to that site's needs.

Choice of Domains

DNSimple offers a custom ALIAS record type that can be used for apex domains (e.g. rather than Or you can set up a lightweight server that accepts requests for and redirects to the correct target.

Cloudfront Cache Invalidation

This gem uses cache invalidation to force new content to be refreshed by CloudFront distributions. This works just fine, but if your content changes often, it's better (and cheaper) to use versioning. See the CloudFront developer guide for details on how to implement a versioning system.

See also


Copyright (c) 2013 Brian P O'Rourke. See LICENSE.txt for further details.