Skip to content

Commit

Permalink
Merge pull request #9721 from SvenDowideit/add-cloudfront-invalidatio…
Browse files Browse the repository at this point in the history
…n-to-docs

Add docs Cloudfront cache invalidation
  • Loading branch information
crosbymichael committed Jan 6, 2015
2 parents ef1dee7 + cfaffd1 commit 4235e27
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ docs-shell: docs-build
$(DOCKER_RUN_DOCS) -p $(if $(DOCSPORT),$(DOCSPORT):)8000 "$(DOCKER_DOCS_IMAGE)" bash

docs-release: docs-build
$(DOCKER_RUN_DOCS) -e OPTIONS -e BUILD_ROOT "$(DOCKER_DOCS_IMAGE)" ./release.sh
$(DOCKER_RUN_DOCS) -e OPTIONS -e BUILD_ROOT -e DISTRIBUTION_ID "$(DOCKER_DOCS_IMAGE)" ./release.sh

docs-test: docs-build
$(DOCKER_RUN_DOCS) "$(DOCKER_DOCS_IMAGE)" ./test.sh
Expand Down Expand Up @@ -83,6 +83,7 @@ build: bundles
docker build -t "$(DOCKER_IMAGE)" .

docs-build:
git diff --name-status upstream/release..upstream/docs docs/ > docs/changed-files
cp ./VERSION docs/VERSION
echo "$(GIT_BRANCH)" > docs/GIT_BRANCH
echo "$(AWS_S3_BUCKET)" > docs/AWS_S3_BUCKET
Expand Down
8 changes: 5 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ to view your results and make sure what you published is what you wanted.

When you're happy with it, publish the docs to our live site:

make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes docs-release
make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes DISTRIBUTION_ID=C2K6......FL2F docs-release

Test the uncached version of the live docs at http://docs.docker.com.s3-website-us-east-1.amazonaws.com/

Note that the new docs will not appear live on the site until the cache (a complex,
distributed CDN system) is flushed. This requires someone with S3 keys. Contact Docker
(Sven Dowideit or John Costa) for assistance.
distributed CDN system) is flushed. The `make docs-release` command will do this
_if_ the `DISTRIBUTION_ID` is set to the Cloudfront distribution ID (ask the meta
team) - this will take at least 15 minutes to run and you can check its progress
with the CDN Cloudfront Chrome addin.

46 changes: 46 additions & 0 deletions docs/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,50 @@ upload_current_documentation() {
$run
}

invalidate_cache() {
if [ "" == "$DISTRIBUTION_ID" ]; then
echo "Skipping Cloudfront cache invalidation"
return
fi

dst=$1

#aws cloudfront create-invalidation --profile docs.docker.com --distribution-id $DISTRIBUTION_ID --invalidation-batch '{"Paths":{"Quantity":1, "Items":["'+$file+'"]},"CallerReference":"19dec2014sventest1"}'
aws configure set preview.cloudfront true

files=($(cat changed-files | grep 'sources/.*$' | sed -E 's#.*docs/sources##' | sed -E 's#index\.md#index.html#' | sed -E 's#\.md#/index.html#'))
files[${#files[@]}]="/index.html"
files[${#files[@]}]="/versions.html_fragment"

len=${#files[@]}

echo "aws cloudfront create-invalidation --profile docs.docker.com --distribution-id $DISTRIBUTION_ID --invalidation-batch '" > batchfile
echo "{\"Paths\":{\"Quantity\":$len," >> batchfile
echo "\"Items\": [" >> batchfile

#for file in $(cat changed-files | grep 'sources/.*$' | sed -E 's#.*docs/sources##' | sed -E 's#index\.md#index.html#' | sed -E 's#\.md#/index.html#')
for file in "${files[@]}"
do
if [ "$file" == "${files[${#files[@]}-1]}" ]; then
comma=""
else
comma=","
fi
echo "\"$dst$file\"$comma" >> batchfile
done

echo "]}, \"CallerReference\":" >> batchfile
echo "\"$(date)\"}'" >> batchfile


echo "-----"
cat batchfile
echo "-----"
sh batchfile
echo "-----"
}


if [ "$OPTIONS" != "--dryrun" ]; then
setup_s3
fi
Expand All @@ -106,10 +150,12 @@ if [ "$BUILD_ROOT" == "yes" ]; then
echo "Building root documentation"
build_current_documentation
upload_current_documentation
invalidate_cache
fi

#build again with /v1.0/ prefix
sed -i "s/^site_url:.*/site_url: \/$MAJOR_MINOR\//" mkdocs.yml
echo "Building the /$MAJOR_MINOR/ documentation"
build_current_documentation
upload_current_documentation "/$MAJOR_MINOR/"
invalidate_cache "/$MAJOR_MINOR"
7 changes: 5 additions & 2 deletions project/RELEASE-CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,17 @@ git checkout -b docs release || git checkout docs
git fetch
git reset --hard origin/release
git push -f origin docs
make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes docs-release
make AWS_S3_BUCKET=docs.docker.com BUILD_ROOT=yes DISTRIBUTION_ID=C2K6......FL2F docs-release
```

The docs will appear on http://docs.docker.com/ (though there may be cached
versions, so its worth checking http://docs.docker.com.s3-website-us-east-1.amazonaws.com/).
For more information about documentation releases, see `docs/README.md`.

Ask Sven, or JohnC to invalidate the cloudfront cache using the CND Planet chrome applet.
Note that the new docs will not appear live on the site until the cache (a complex,
distributed CDN system) is flushed. The `make docs-release` command will do this
_if_ the `DISTRIBUTION_ID` is set correctly - this will take at least 15 minutes to run
and you can check its progress with the CDN Cloudfront Chrome addin.

### 12. Create a new pull request to merge release back into master

Expand Down

0 comments on commit 4235e27

Please sign in to comment.