Merge pull request #4679 from hashicorp/sethvargo/deploy
Migrate to static site deploymentspull/4694/head
@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Switch to the stable-website branch
|
||||
git checkout stable-website
|
||||
|
||||
# Set the tmpdir
|
||||
if [ -z "$TMPDIR" ]; then
|
||||
TMPDIR="/tmp"
|
||||
fi
|
||||
|
||||
# Create a temporary build dir and make sure we clean it up. For
|
||||
# debugging, comment out the trap line.
|
||||
DEPLOY=`mktemp -d $TMPDIR/terraform-www-XXXXXX`
|
||||
trap "rm -rf $DEPLOY" INT TERM EXIT
|
||||
|
||||
# Get the parent directory of where this script is.
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
|
||||
|
||||
# Copy into tmpdir
|
||||
shopt -s dotglob
|
||||
cp -r $DIR/website/* $DEPLOY/
|
||||
|
||||
# Change into that directory
|
||||
pushd $DEPLOY &>/dev/null
|
||||
|
||||
# Ignore some stuff
|
||||
touch .gitignore
|
||||
echo ".sass-cache" >> .gitignore
|
||||
echo "build" >> .gitignore
|
||||
echo "vendor" >> .gitignore
|
||||
|
||||
# Add everything
|
||||
git init -q .
|
||||
git add .
|
||||
git commit -q -m "Deploy by $USER"
|
||||
|
||||
git remote add heroku git@heroku.com:terraform-www.git
|
||||
git push -f heroku master
|
||||
|
||||
# Go back to our root
|
||||
popd &>/dev/null
|
||||
@ -1,2 +0,0 @@
|
||||
https://github.com/heroku/heroku-buildpack-ruby.git
|
||||
https://github.com/hashicorp/heroku-buildpack-middleman.git
|
||||
@ -0,0 +1,2 @@
|
||||
---
|
||||
BUNDLE_DISABLE_SHARED_GEMS: '1'
|
||||
@ -1 +0,0 @@
|
||||
web: bundle exec thin start -p $PORT
|
||||
@ -0,0 +1,41 @@
|
||||
{
|
||||
"variables": {
|
||||
"aws_access_key_id": "{{ env `AWS_ACCESS_KEY_ID` }}",
|
||||
"aws_secret_access_key": "{{ env `AWS_SECRET_ACCESS_KEY` }}",
|
||||
"aws_region": "{{ env `AWS_REGION` }}",
|
||||
"fastly_api_key": "{{ env `FASTLY_API_KEY` }}"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "docker",
|
||||
"image": "ruby:2.3-slim",
|
||||
"commit": "true"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "file",
|
||||
"source": ".",
|
||||
"destination": "/app"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"environment_vars": [
|
||||
"AWS_ACCESS_KEY_ID={{ user `aws_access_key_id` }}",
|
||||
"AWS_SECRET_ACCESS_KEY={{ user `aws_secret_access_key` }}",
|
||||
"AWS_REGION={{ user `aws_region` }}",
|
||||
"FASTLY_API_KEY={{ user `fastly_api_key` }}"
|
||||
],
|
||||
"inline": [
|
||||
"apt-get update",
|
||||
"apt-get install -y build-essential curl git libffi-dev s3cmd wget",
|
||||
"cd /app",
|
||||
|
||||
"bundle check || bundle install --jobs 7",
|
||||
"bundle exec middleman build",
|
||||
|
||||
"/bin/bash ./scripts/deploy.sh"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
PROJECT="terraform"
|
||||
PROJECT_URL="www.terraform.io"
|
||||
FASTLY_SERVICE_ID="7GrxRJP3PVBuqQbyxYQ0MV"
|
||||
|
||||
# Ensure the proper AWS environment variables are set
|
||||
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
|
||||
echo "Missing AWS_ACCESS_KEY_ID!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
|
||||
echo "Missing AWS_SECRET_ACCESS_KEY!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure the proper Fastly keys are set
|
||||
if [ -z "$FASTLY_API_KEY" ]; then
|
||||
echo "Missing FASTLY_API_KEY!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure we have s3cmd installed
|
||||
if ! command -v "s3cmd" >/dev/null 2>&1; then
|
||||
echo "Missing s3cmd!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the parent directory of where this script is and change into our website
|
||||
# directory
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
||||
DIR="$(cd -P "$( dirname "$SOURCE" )/.." && pwd)"
|
||||
|
||||
# Delete any .DS_Store files for our OS X friends.
|
||||
find "$DIR" -type f -name '.DS_Store' -delete
|
||||
|
||||
# Upload the files to S3 - we disable mime-type detection by the python library
|
||||
# and just guess from the file extension because it's surprisingly more
|
||||
# accurate, especially for CSS and javascript. We also tag the uploaded files
|
||||
# with the proper Surrogate-Key, which we will later purge in our API call to
|
||||
# Fastly.
|
||||
if [ -z "$NO_UPLOAD" ]; then
|
||||
echo "Uploading to S3..."
|
||||
|
||||
# Check that the site has been built
|
||||
if [ ! -d "$DIR/build" ]; then
|
||||
echo "Missing compiled website! Run 'make build' to compile!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
s3cmd \
|
||||
--quiet \
|
||||
--delete-removed \
|
||||
--guess-mime-type \
|
||||
--no-mime-magic \
|
||||
--acl-public \
|
||||
--recursive \
|
||||
--add-header="Cache-Control: max-age=31536000" \
|
||||
--add-header="x-amz-meta-surrogate-key: site-$PROJECT" \
|
||||
sync "$DIR/build/" "s3://hc-sites/$PROJECT/latest/"
|
||||
fi
|
||||
|
||||
# Perform a soft-purge of the surrogate key.
|
||||
if [ -z "$NO_PURGE" ]; then
|
||||
echo "Purging Fastly cache..."
|
||||
curl \
|
||||
--fail \
|
||||
--silent \
|
||||
--output /dev/null \
|
||||
--request "POST" \
|
||||
--header "Accept: application/json" \
|
||||
--header "Fastly-Key: $FASTLY_API_KEY" \
|
||||
--header "Fastly-Soft-Purge: 1" \
|
||||
"https://api.fastly.com/service/$FASTLY_SERVICE_ID/purge/site-$PROJECT"
|
||||
fi
|
||||
|
||||
# Warm the cache with recursive wget.
|
||||
if [ -z "$NO_WARM" ]; then
|
||||
echo "Warming Fastly cache..."
|
||||
wget \
|
||||
--recursive \
|
||||
--delete-after \
|
||||
--quiet \
|
||||
"https://$PROJECT_URL/"
|
||||
fi
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 498 B After Width: | Height: | Size: 479 B |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 815 B After Width: | Height: | Size: 700 B |
|
Before Width: | Height: | Size: 980 B After Width: | Height: | Size: 977 B |
|
Before Width: | Height: | Size: 838 B After Width: | Height: | Size: 784 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 162 B |
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 193 B |
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 973 B |
|
Before Width: | Height: | Size: 556 B After Width: | Height: | Size: 546 B |
|
Before Width: | Height: | Size: 994 B After Width: | Height: | Size: 975 B |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 264 KiB After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 63 KiB |