Skip to content
Uploads static assets to S3 when deploying to heroku
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead, 3 commits behind Lostmyname:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
.gitignore
README.md
package.json

README.md

Purpose

Uploads static assets to S3 when deploying to heroku. Requires NodeJS to be installed when building.

Setting Mandatory Environment Variables for build

AWS_ACCESS_KEY_ID=<aws access key id>
AWS_SECRET_ACCESS_KEY=<aws secret access key>
AWS_DEFAULT_REGION=<aws-region>
AWS_STATIC_BUCKET_NAME=<s3-bucket-name>
# prefix to include in path
AWS_STATIC_PREFIX=static
# The directory to upload to S3 (uploads the content of the directory)
AWS_STATIC_SOURCE_DIRECTORY=public

Exported Environment Variables to runtime

STATIC_SERVER=<AWS_STATIC_BUCKET_NAME>.s3.amazonaws.com
STATIC_PATH=/<AWS_STATIC_PREFIX>/<YYYY-MM-DD>/<git-commit-sha1>

These variables can be overriden with config vars as expected

heroku config:set STATIC_SERVER=your.cdn.host

To return to the default value just unset the config vars

heroku config:unset STATIC_SERVER
You can’t perform that action at this time.